Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: cron not executing my cron job?

  1. #1

    Default cron not executing my cron job?

    Hi All,

    I am a happy user of Opensuse 13.1 KDE, but a cron job for a backup script I use does not run for some reason - it worked perfectly in opensuse kde 12.3.

    The line in my crontab is:

    Code:
    10 11 * * 1 /home/david/Scripts/doPersonalBackup.sh
    (i.e 11:10am every Sunday)

    If i run /home/david/Scripts/doPersonalBackup.sh from the command line it works fine, for some reason the cron job does not execute?

    Just to make absolutely sure, I checked services in yast2 and cron is enabled and starts at boot. I would be grateful for any help.

    Cheers,

    David

  2. #2
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,002

    Default Re: cron not executing my cron job?

    Does the .sh file have +x bit set?

    If not, run it with sh​ or set +x.
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  3. #3

    Default Re: cron not executing my cron job?

    On 12/02/2013 03:06 AM, londondaveuk wrote:
    >
    > Code:
    > --------------------
    > 10 11 * * 1 /home/david/Scripts/doPersonalBackup.sh
    > --------------------
    > (i.e 11:10am every Sunday)


    Um.... no. This states to run every Monday, not Sunday. By the time you
    read this it may have magically fixed itself, by running today. :-)

    man 5 crontab

    --
    Good luck.

    If you find this post helpful and are logged into the web interface,
    show your appreciation and click on the star below...

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,729

    Default Re: cron not executing my cron job?

    Quote Originally Posted by londondaveuk View Post
    Hi All,

    I am a happy user of Opensuse 13.1 KDE, but a cron job for a backup script I use does not run for some reason - it worked perfectly in opensuse kde 12.3.

    The line in my crontab is:

    Code:
    10 11 * * 1 /home/david/Scripts/doPersonalBackup.sh
    (i.e 11:10am every Sunday)

    If i run /home/david/Scripts/doPersonalBackup.sh from the command line it works fine, for some reason the cron job does not execute?

    Just to make absolutely sure, I checked services in yast2 and cron is enabled and starts at boot. I would be grateful for any help.

    Cheers,

    David
    You may have the impression that the job does not run, but you tell us nothing that poves it.
    At least you could put a statment in the beginning of that sript (so you are almost 100% that it is executed when the script is called) like
    Code:
    touch /tmp/lasttimemyscriptrunned
    or an echo to some file with dat/time included (many posibilities). But just telling us that it does not work gives us nor you any information.

    And of course a step in the whole debugginng process is showing (proving) that that file exists and what its properties are:
    Code:
    ls -l /home/david/Scripts/doPersonalBackup.sh
    Last edited by hcvv; 02-Dec-2013 at 05:50.
    Henk van Velden

  5. #5

    Default Re: cron not executing my cron job [SOLVED]

    Thanks ab,

    You are absolutely right it ran today. Why did it run on Sundays in opensuse 12.3 but now it's on a Monday? It makes sense to me that day 1 is a Monday, was there a change in the way cron works?

    Thanks again to all that replied.

  6. #6

    Default Re: cron not executing my cron job?

    On 12/02/2013 10:16 AM, londondaveuk wrote:
    >
    > Thanks ab,
    >
    > You are absolutely right it ran today. Why did it run on Sundays in
    > opensuse 12.3 but now it's on a Monday? It makes sense to me that day 1
    > is a Monday, was there a change in the way cron works?


    Wildly guessing..... your date was off? Maybe your memory of the old way
    is off?

    I guess it could have been an issue in cron, but I have never seen that
    before personally. With that said, I seldom use the day-of-week field in
    cron so don't give me too much credit there.

    --
    Good luck.

    If you find this post helpful and are logged into the web interface,
    show your appreciation and click on the star below...

  7. #7
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: cron not executing my cron job?

    On 2013-12-02 18:16, londondaveuk wrote:
    >
    > Thanks ab,
    >
    > You are absolutely right it ran today. Why did it run on Sundays in
    > opensuse 12.3 but now it's on a Monday? It makes sense to me that day 1
    > is a Monday, was there a change in the way cron works?


    crontab(5)

    Code:
    The time and date fields are:
    
    field          allowed values
    -----          --------------
    minute         0-59
    hour           0-23
    day of month   1-31
    month          1-12 (or names, see below)
    day of week    0-7 (0 or 7 is Sunday, or use names)
    Thus "10 11 * * 1" is certainly a Monday.

    The version of cron we use is "Cronie", I don't know if other versions
    have different definitions for weekdays. You can use names instead, the
    manual says.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.3 x86_64 "Dartmouth" at Telcontar)

  8. #8

    Default Re: cron not executing my cron job?

    Similarly, my job does not run in cron, however it runs fine when I call the script.

    It is: 0 1 * * * /home/jim/backup.sh > "/tmp/backup$(date + %Y-%M-%D_%H:%M).log"

    I have set the bios to wake 5 minutes before 1am. Even though under KDE Control Module Energy Saving, I have un-checked suspend system, should my cron job be scheduled under root?

  9. #9

    Default Re: cron not executing my cron job?

    Similarly, my job does not run in cron, however it runs fine when I call the script.

    It is: 0 1 * * * /home/jim/backup.sh > "/tmp/backup$(date + %Y-%M-%D_%H:%M).log"

    I have set the bios to wake 5 minutes before 1am. Even though under KDE Control Module Energy Saving, I have un-checked suspend system, should my cron job be scheduled under root?

  10. #10
    Join Date
    Sep 2012
    Location
    Canada
    Posts
    112

    Default Re: cron not executing my cron job?

    Quote Originally Posted by jgilbe View Post
    Similarly, my job does not run in cron, however it runs fine when I call the script.

    It is: 0 1 * * * /home/jim/backup.sh > "/tmp/backup$(date + %Y-%M-%D_%H:%M).log"

    I have set the bios to wake 5 minutes before 1am. Even though under KDE Control Module Energy Saving, I have un-checked suspend system, should my cron job be scheduled under root?
    Hi jgilbe and welcome to the openSUSE community forum,

    Because your problem isn't exactly the same than the original poster, and because you should have started another thread for the problem your are encountering. Anyway, your problem can easily be fixed. The % character has a special meaning in crontab:

    Quote Originally Posted by man 5 crontab
    [...]

    The "sixth" field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or a "%" character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. A "%" character in the command, unless escaped with a backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

    [...]
    Just escape the % character using \ in crontab and all should be fine.
    Kalten

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •