Results 1 to 2 of 2
I do have a large number of cronjobs that I want to consolidate. The cronjobs are all calling the same script, but with a job specific tag. The jobs execute ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-24-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 1
cronjob - shell script related problem
I do have a large number of cronjobs that I want to consolidate. The cronjobs are all calling the same script, but with a job specific tag. The jobs execute an application backup job using a different configuration file. I have a total of 20 jobs and 20 different (pre-configured) configuration files. The jobs get executed in a 6 hour period one after another. Each job is a required pre-requisite for the next job to be successfully executed.
Somebody suggested that I should dump the commands into a shell script and then run a single cronjob against the shell script. Now I do not know how the shell script execution 'behaves' in regards to execution. Let's say I list my 20 crons one after another. How is that being executed? Does the script executes line 1 first and waits for the success message and then moves to line 2 and so on? Or what better way can I use to run my cronjobs? Here is an example of my jobs:
Any ideas?25 18 * * 5 /usr/local/v-backup/v-backup.pl -c /usr/local/v-backup/app-1-backup.cfg > /var/log/vbackup/app-1-backup.log
55 18 * * 5 /usr/local/v-backup/v-backup.pl -c /usr/local/v-backup/app-2-backup.cfg > /var/log/vbackup/app-2-backup.log
25 19 * * 5 /usr/local/v-backup/v-backup.pl -c /usr/local/v-backup/app-3-backup.cfg > /var/log/vbackup/app-3-backup.log
and so on ....
Thanks.
Chris
- 10-26-2007 #2Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
Shell scripts can run commands either. Just the command, like so:
will wait for the command to finish before moving on. Putting an & after it:Code:/usr/bin/something
spawns it in the background and moves on without waiting. Also, you can have a command run only if the previous commands run by using && :Code:/usr/bin/something &
This way the third one won't execute unless the first two both exited successfully. The fancy way is to use some if statements to find the return value and if one command doesn't finish, it will tell you where it stopped. Look into bash scripting and there's a bit more you can do.Code:/usr/bin/something --run-first && /usr/bin/something --run-second && /usr/bin/something --run-third


Reply With Quote
