LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Suse/Novell (http://www.linuxquestions.org/questions/suse-novell-60/)
-   -   cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? (http://www.linuxquestions.org/questions/suse-novell-60/cron-not-working-from-crontab-nor-form-etc-cron-cron-d-what-did-suse-change-515532/)

JZL240I-U 01-02-2007 05:07 AM

cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change?
 
Or did I overlook something? :scratch:

My goal is to automate backups. I had tested rsnapshot for correct configuration (option -t) and tested it by hand starting rsnapshot with
Code:

rsnapshot hourly
rsnapshot daily

which resulted in the wanted backups.

Then as root I entered via "crontab -e":
Code:

0    */2  *    *    *    /usr/local/bin/rsnapshot hourly
50  23  *    *    *    /usr/local/bin/rsnapshot daily
40  23  1,8,15,22    *    *    /usr/local/bin/rsnapshot weekly
30  23  1    *    *    /usr/local/bin/rsnapshot monthly


The computer has been restarted since, lots of times -- nothing happened.

Next, as an alternative, I copied those crontab lines to a file in /etc/cron/cron.d (where also the beagle entry resides) and hoped for the best -- all in vain.

The time difference between my running of rsnapshot and the cron job is huge (months in fact), so the thing really should run -- but doesn't.

From the documentation I gathered that SuSE expects scripts in /etc/cron/cron.hourly - */daily etc. but how can I trigger rsnapshot from there at times like those in my crontab file? I mean I could just create a shell script with
Code:

/usr/local/bin/rsnapshot hourly
in the /etc/cron/cron.hourly directory but how to do it only every two hours as in
Code:

0    */2  *    *    *  /command/to/run
?

Since the experts are (hopefully ;)) here: where is the crontab-generated file located by the by? Didn't find it ... does it have a name with no "cron" in it?

Can i "nice" the command (at a time it is finally runnig as desired :rolleyes:)?

billymayday 01-02-2007 02:50 PM

Can you get anything to run from a user's crontab (even just to send a basic message to the user)?

billymayday 01-02-2007 03:13 PM

Actually another question (I don't claim to be a crontab expert - I just use it occasionally). Did it occur to you that this is possibly parameter passing problem, in that crontab thinks the parameter "hourly" for example is a parameter to crontab not rsnapshot (since this is where the output parameter would normally go for crontab entries)?

Why don't you create a simple shell file (say /root/rsnapshot.hourly.sh) that only has something like

Quote:

#!/bin/sh
/usr/local/bin/rsnapshot hourly
get that to work fine from the command line, and then try

0 */2 * * * /root/rsnapshot.hourly.sh

in crontab

JZL240I-U 01-03-2007 02:33 AM

Hi billymayday, thanks for answering. I haven't tried as user, as it is about a backup (among others of "/etc") I wanted to run "rsnapshot" as root, but I could try.

Your second post sounds very plausible. Could I quote in crontab? I mean, a lot of people will have needed something like this already so I'd guess it is provided for in crontab one just had to find out how ;). I'll try
Code:

0    */2  *    *    *    '/usr/local/bin/rsnapshot hourly'
and if it doesn't work your suggestion. I'll be back tomorrow with the results. Thanks again :).

billymayday 01-03-2007 03:57 AM

You can edit crontab as root you know - root's a user too!

JZL240I-U 01-03-2007 04:03 AM

That is exactly what I did:
Quote:

Originally Posted by JZL240I-U
...Then as root I entered via "crontab -e":
Code:

0    */2  *    *    *    /usr/local/bin/rsnapshot hourly
50  23  *    *    *    /usr/local/bin/rsnapshot daily
40  23  1,8,15,22    *    *    /usr/local/bin/rsnapshot weekly
30  23  1    *    *    /usr/local/bin/rsnapshot monthly


...

I still think your suggestion concerning the parameter / quoting problem is probably close to the mark. Like I said, I'll try it tonight (sitting at a Win-box right now).

billymayday 01-03-2007 04:07 AM

Before you try any of this, can you check where rsnapshot lives in SuSe land?

I just yum'ed a copy onto a spare CentOS server and it's in /usr/bin not /usr/local/bin. Could easily be your problem.

Looking at the man page for rsnapshot, it looks like what you tried should wotk if the path is OK

JZL240I-U 01-03-2007 04:09 AM

Uuups. I'll have a look. Thanks a load :).

hameedkhan 01-03-2007 04:20 AM

Quote:

Originally Posted by JZL240I-U

From the documentation I gathered that SuSE expects scripts in /etc/cron/cron.hourly - */daily etc. but how can I trigger rsnapshot from there at times like those in my crontab file? I mean I could just create a shell script with [/FONT]
Code:

/usr/local/bin/rsnapshot hourly
in the /etc/cron/cron.hourly directory but how to do it only every two hours as in
Code:

0    */2  *    *    *  /command/to/run

For SuSe 10 you can put your crontab entries in /root/bin/cron.daily.local. entries in /etc/cron.d/ are not run automatically at later time. and the entries added or edited by "crontab" command are locate in /var/spool/cron/tabs/ in files matching the usernames.

Don't put your entires in /etc/cron.* files because these scripts are overwritten when you update your system. Add your entries in above mentioned file.

JZL240I-U 01-03-2007 04:24 AM

Ah, something about SuSE internals, that's why I posted in the SuSE subforum ;). Thanks hameedkhan I'll give it a go.

billymayday 01-03-2007 05:06 AM

Googling for suse rsnapshot showed me this:

http://rpmfind.net/linux/RPM/opensus...28.noarch.html

and in part it says

Quote:

Files

/etc/rsnapshot.conf
/etc/rsnapshot.conf.default
/usr/bin/rsnapshot
/usr/bin/rsnapshot-diff
/usr/share/doc/packages/rsnapshot
/usr/share/doc/packages/rsnapshot/AUTHORS
/usr/share/doc/packages/rsnapshot/COPYING
/usr/share/doc/packages/rsnapshot/ChangeLog
/usr/share/doc/packages/rsnapshot/INSTALL
/usr/share/doc/packages/rsnapshot/README
/usr/share/doc/packages/rsnapshot/TODO
/usr/share/man/man1/rsnapshot.1.gz

JZL240I-U 01-04-2007 02:57 AM

Hit and sunk :D

You did it billymayday it was the wrong path as you'd already correctly guessed. After deleting the "/local" part from it, everything works and no quoting needed either.

Oh, and I simply copied the paths from http://www.die.net/doc/linux/man/man1/rsnapshot.1.html so, other newbies beware ;) -- generally the information is really good on that site which I commend, it was my error, not looking what my system did during install.

@hameedkhan right on, I found the entries in /var/spool/cron/tabs/ thanks for the information.

As to putting the entries into /root/bin/cron.daily.local etc. that would not have the desired effect (I think). You probably know that SuSE has a script which tests whether cron jobs were not executed during shutdown time and makes cron catch up on everything contained in /etc/cron/cron.hourly - *.daily - *.weekly. My box is a stand-alone workstation. Since I back up /etc it is not too much hassle to get it back after an update.

I'm thinking about using fcron now: http://fcron.free.fr/

How is beagle started by the way? Anybody knows technical details?


All times are GMT -5. The time now is 08:24 AM.