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:

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

Does the .sh file have +x bit set?

If not, run it with sh​ or set +x.

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. :slight_smile:

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…

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

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:

ls -l /home/david/Scripts/doPersonalBackup.sh

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.

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…

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)


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)

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?

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:

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

Just an afterthought,

In your call of the date program, you seem to have a space character between + and the description of the date format (%Y-%M-%D_%H:%M). The correct syntax would be:


date +%Y-%M-%D_%H:%M

Don’t forget to escape the % character!

Thanks Kalten, worked great.

What I do to help me remember the syntax is comment at the top of the file


# Minute   Hour   Day of Month       Month               Day of Week              Command
# (0-59)    (0-23)     (1-31)         (1-12 or Jan-Dec)     (0-6 or Sun-Sat)


You are welcome,

Have fun with openSUSE!