Click to See Complete Forum and Search --> : Question about cron and how it works
Energon
12-27-2000, 05:07 PM
Hello, I'm sure this has been answered a million times before, but I'm a little stumped on how to do it. I've been reading the cron manpages and checking various default crontabs... but I'm still not quite sure on how to get it done...
basically what I want is to have a script run as root every night at 11pm.. it's a log rotation script... and then I want a backup script to run at midnight every night... hopefully that will get my server backed up every night instead of "when I remember"...
I have the scripts all set to go for automation in /usr/local/sbin, I just need to get cron to start executing them... so if anyone can give me some tips on what to put in my /var/spool/cron/crontabs/root file so that this will happen, and maybe a little explanation so I can start doing more things like that, I'd appreciate it... http://www.linuxnewbie.org/ubb/smile.gif
Whipping Boy
12-27-2000, 06:47 PM
00 23 * * * script &
At least if you're using Dillon's crond (you probably are), you should, instead of calling each script one after the other, call a master script that runs all the scripts. The reason is that Dillon's crond can only run one job at a time, and if one job happens to run past the time the next job is slated to start, it won't run the second one. And always remember to amp off your crontab entries.
------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!
White, heterosexual, middle-class, and proud!
I've never understood why Bill Gates would name his company after his penis
Energon
12-28-2000, 05:27 PM
ohhh... so basically the 00 = midnight and the 23 = 11 pm, like on a 24 hour clock? If I wanted one main script would I do this:
00 * * * * script &
? I'm not sure what the *s are for though... http://www.linuxnewbie.org/ubb/frown.gif
I'll get myself a master script that will run at 11... I figured it'd run them regardless, but if it can hit one at a time, that's perfectly okay with me...
thanks for the help... http://www.linuxnewbie.org/ubb/smile.gif
Energon
12-28-2000, 05:39 PM
wait... scratch that... you're saying at 23:00 every day of every month, eveyr day of the week...
wow... that's cool... I get it now... so I'm going to assume that midnight comes out to be this:
00 00 * * * script &
right?
Whipping Boy
12-28-2000, 07:55 PM
Yep--you've got it.
------------------
Kurt Weber
Shell scripts? Shell scripts? We don't NEED no stinkin' shell scripts!
White, heterosexual, middle-class, and proud!
I've never understood why Bill Gates would name his company after his penis
iDxMan
12-28-2000, 08:00 PM
Yes, 0 0 * * * script & should work.
Then again, it depends on what cron you are using. Some, such as Vixie cron, use the "system" crontab file (usually /etc/crontab) which executes run-parts for /etc/cron.daily, /etc/cron.monthly, and so on.
If you edit this main file, then you'll probably need something like :
0 0 * * * root script &
Since this is a system crontab file it needs to know who to run under. But you should be ok if you do a "crontab -e" which lets you modify /var/spool/cron/crontabs/root ..
-r
ps. the *'s are wildcards.
mdwatts
12-28-2000, 08:50 PM
You might want to read this http://www.linuxnewbie.org/nhf/intel/misc/scheduling.html