8 Replies Latest reply: Feb 21, 2014 11:19 AM by jh_ellis RSS

Cron jobs not running

jh_ellis Newbie
Currently Being Moderated

Hi

I am using linux 5.x

(

uname -r

2.6.18-348.16.1.0.1.el5PAE

)

 

I have 2 crontab jobs set up as following .

cat backup_confluence.sh

#!/bin/bash

# bash shell script to backup confluence backups to bccpfr

# Schedule this script after the backups are performed that day

#

# Setup the environment for the bourne-again shell

. ./.bash_profile

#

# Copy the daily backups for confluence

find /usr/share/confluence/data/backups -mtime -1 \! -type d -exec ls {} \; -exec scp {} bccpfr:/usr/backup/confluence \;

 

second

cat  backup_jira.sh

#!/bin/bash

# bash shell script to backup jira backups to bccpfr

# Schedule this script after the backups are performed that day

#

# Setup the environment for the bourne-again shell

. ./.bash_profile

#

# Copy the daily backups for jira

find /usr/share/jira/backups -mtime -1 \! -type d -exec ls {} \; -exec scp {} bccpfr:/usr/backup/jira \;

 

cron as following

$ crontab -l

13 06 * * * /home/lsg/backup_jira.sh

18 06 * * * /home/lsg/backup_confluence.sh

 

Issue

Both the above .sh are running properly when executed  manually but they are not running automatically at the given time crontab job.

 

Kindly help me on this issue.

many thanks

J

  • 1. Re: Cron jobs not running
    TommyReynolds Expert
    Currently Being Moderated

    When I want to do anything too complicated to fit on one crontab line, I do this:

     

    13 06 * * * /bin/bash -l -c '/home/lsg/backup_jira.sh'

     

    This simulates a login(1) environment similar to that you ordinarily see from the command line.  By default, cron(1) does not try to replicate your shell environment.

     

    Of course it is possible to write the cron(1) command so it does not make any assumptions about its execution environment, but this is easier for the novice.

  • 2. Re: Cron jobs not running
    jh_ellis Newbie
    Currently Being Moderated

    Thanks for the reply Tommy. BTW I have had very little exposure to using crontab; except editing some backup programs in Unix years ago and that was with support. in fact my background was primarily in hardware support (Windows, SCO-unix, AIX unix and some Linux) before I took this position a little less than two years ago. Also I had never heard of or used the programs jira or confluence before this job. Can you expand on what you mean by login(1)?

  • 3. Re: Cron jobs not running
    Dude! Guru
    Currently Being Moderated

    Is your crontask not running at all or is the scheduled task failing?

    Do you have execute permission set on the scripts?

    Any info in /var/log/messages or e-mail?

     

    What happens if you schedule a task that runs every minute, for example:

     

    crontab -e

    * * * * * echo $(date) >> /tmp/cronout

     

    cat /tmp/cronout

    Mon Feb 10 17:54:02 CET 2014

    Mon Feb 10 17:55:01 CET 2014

    Do you get the output?

  • 4. Re: Cron jobs not running
    jh_ellis Newbie
    Currently Being Moderated

    Say Tommy from what I have read about creating cron jobs the sixth part of a job should be the user performing it; shown right before the command itself. In my case that would be the user called lsg and I don't see that in my jobs, or does that not need to be there, as the command goes to the /home/lsg folder; where the backup scripts are?

  • 5. Re: Cron jobs not running
    jh_ellis Newbie
    Currently Being Moderated

    Is your crontask not running at all or is the scheduled task failing?

    Hey Tommy I sent you some replies yesterday; don't know what happened to them. Yes I can see that crond runs every ten minutes. Also when I created the crontab file using the command you sent here I could see that it was running every minute by looking at root mail in /var/log.

     

    Do you have execute permission set on the scripts?

    Yes

     

    Any info in /var/log/messages or e-mail?

    Output from mail-

    From root@razorback  Tue Feb 11 08:19:01 2014
    Return-Path: <root@razorback>
    Received: from razorback (localhost [127.0.0.1])
        by razorback (8.13.8/8.13.8) with ESMTP id s1BEJ154018231
        for <root@razorback>; Tue, 11 Feb 2014 08:19:01 -0600
    Received: (from root@localhost)
        by razorback (8.13.8/8.13.8/Submit) id s1BEJ1rh018198;
        Tue, 11 Feb 2014 08:19:01 -0600
    Date: Tue, 11 Feb 2014 08:19:01 -0600
    Message-Id: <201402111419.s1BEJ1rh018198@razorback>
    From: root@razorback (Cron Daemon)
    To: root@razorback
    Subject: Cron <root@razorback> $(date) >> /tmp/cronout
    Content-Type: text/plain; charset=UTF-8
    Auto-Submitted: auto-generated
    X-Cron-Env: <SHELL=/bin/sh>
    X-Cron-Env: <HOME=/root>
    X-Cron-Env: <PATH=/usr/bin:/bin>
    X-Cron-Env: <LOGNAME=root>
    X-Cron-Env: <USER=root>

    /bin/sh: Tue: command not found

    From root@razorback  Tue Feb 11 08:20:02 2014
    Return-Path: <root@razorback>
    Received: from razorback (localhost [127.0.0.1])
        by razorback (8.13.8/8.13.8) with ESMTP id s1BEK2BD018267
        for <root@razorback>; Tue, 11 Feb 2014 08:20:02 -0600
    Received: (from root@localhost)
        by razorback (8.13.8/8.13.8/Submit) id s1BEK1mT018238;
        Tue, 11 Feb 2014 08:20:01 -0600
    Date: Tue, 11 Feb 2014 08:20:01 -0600
    Message-Id: <201402111420.s1BEK1mT018238@razorback>
    From: root@razorback (Cron Daemon)
    To: root@razorback
    Subject: Cron <root@razorback> $(date) >> /tmp/cronout
    Content-Type: text/plain; charset=UTF-8
    Auto-Submitted: auto-generated
    X-Cron-Env: <SHELL=/bin/sh>
    X-Cron-Env: <HOME=/root>
    X-Cron-Env: <PATH=/usr/bin:/bin>
    X-Cron-Env: <LOGNAME=root>
    X-Cron-Env: <USER=root>

    /bin/sh: Tue: command not found

  • 6. Re: Cron jobs not running
    jh_ellis Newbie
    Currently Being Moderated

    Ok I understand when mean set up in line to override the default Bash variable in job runtime itself.

    But I hit another blocker at this time which show as below.

    From lsg@razorback  Tue Feb 11 10:41:02 2014

    Return-Path: <lsg@razorback>

    Received: from razorback (localhost [127.0.0.1])

        by razorback (8.13.8/8.13.8) with ESMTP id s1BGf1VX024611

        for <lsg@razorback>; Tue, 11 Feb 2014 10:41:01 -0600

    Received: (from lsg@localhost)

        by razorback (8.13.8/8.13.8/Submit) id s1BGf17A024453;

        Tue, 11 Feb 2014 10:41:01 -0600

    Date: Tue, 11 Feb 2014 10:41:01 -0600

    Message-Id: <201402111641.s1BGf17A024453@razorback>

    From: root@razorback (Cron Daemon)

    To: lsg@razorback

    Subject: Cron <lsg@razorback> /bin/bash -l -c /home/lsg/backup_jira.sh

    Content-Type: text/plain; charset=UTF-8

    Auto-Submitted: auto-generated

    X-Cron-Env: <SHELL=/bin/sh>

    X-Cron-Env: <HOME=/home/lsg>

    X-Cron-Env: <PATH=/usr/bin:/bin>

    X-Cron-Env: <LOGNAME=lsg>

    X-Cron-Env: <USER=lsg>

     

    Agent pid 2451

    Agent pid 2451

    /usr/share/jira/backups/2014-Feb-11--0919.zip

    Permission denied, please try again.

    Permission denied, please try again.

    Permission denied (publickey,password).

    lost connection

    /usr/share/jira/backups/2014-Feb-10--2118.zip

    Permission denied, please try again.

    Permission denied, please try again.

    Permission denied (publickey,password).

    lost connection

     

     

     

     

    Kindly suggest.

  • 7. Re: Cron jobs not running
    jh_ellis Newbie
    Currently Being Moderated

    OK this is where we are at now. After re-installing the ssh completely I now get the following when trying to run the backup command that copies the files over from the "razorback" server to the remote server (bccpfr)

    [lsg@razorback ~]$ ./backup_jira.sh
    Agent pid 2451
    /usr/share/jira/backups/2014-Feb-12--2122.zip
    lsg@bccpfr's password:

    It is still asking for a password for the remote server user.

     

    Any thoughts please respond,

    Thanks

  • 8. Re: Cron jobs not running
    jh_ellis Newbie
    Currently Being Moderated

    When I look at the cron file in /var/log it shows crond running every 10 minutes but these jobs do not show up there. The 2 backup jobs are set to –rwxr-xr-x and are owned by the user lsg in the lsg group. I will create the cron entry you suggested and see what happens.

     

     

     

    John Ellis

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points