Setting cronjobs...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting cronjobs...
# 1  
Old 06-06-2008
Setting cronjobs...

Hi,

We have 4 jobs to be run every month on different times -
* a daily job runs once in 2 days at 3PM
*a weekly runs every thursday at 3PM
* a monthly runs last day of month either 30 or 31st at 3PM
* 4th job runs on 3rd of every month at 3Pm

How can I set the crontab for these 4 jobs without clash?
i,e if a weekly job comes on 3rd then 4th job should take the precedence, and weekly should run the next day.similarly if any other job clashes with job running on month end, the monthly job should take precedence..

looking for suggestions and help...
# 2  
Old 06-06-2008
You can run multiple cronjobs at a time without clashing in Unix. Each will run as a background process.
Add this tag at the end of your cron job:

>/dev/null 2>&1

Example of your cron job looks like:

30 23 * * * /home/username/www/cgi-bin/members.cgi> /dev/null 2>&1
# 3  
Old 06-06-2008
If not running them at the same time is a requirement, you need to implement some additional logic. Perhaps wrap each of the scripts inside a wrapper which decides whether to run or not, based on your criteria, or based on the existence of a lock file (but then you still need to figure out how to make the correct one run and create the lock file in the first place).

Actually maybe it's easier to have a single cron job which runs a script which decides whether it should run the monthly, weekly etc job.

@incredible: what does redirection have with this to do?
# 4  
Old 06-06-2008
I was just showing an example of cron entry. Anyway, he should not have any problems running all the crons at one go
# 5  
Old 06-06-2008
There may be external factors which force the requirement to not run in parallel. For example, maybe it's a database cleanup job which needs exclusive access to the database, and should run with different parameters on different days.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to find all Cronjobs?

Hey Guys, i've got a big issue... I've to find all running scripts in all crontabs. Is there a possibility to display all crontabs of each user? What i've already tried? The following script: for user in $(cut -f1 -d: /etc/passwd); do crontab -l $user; done I'm already root but i didn't... (3 Replies)
Discussion started by: Marcusg562
3 Replies

2. Shell Programming and Scripting

Facing issues with cronjobs

Hello Everyone, We have a cronjob scheduled to pick up files from one system and transfer to another system. the underlying code is a shell script. These cronjobs were working correctly until sometime. 2 days back they did not pick up the scripts but created empty logs. However when we tried... (6 Replies)
Discussion started by: Rads
6 Replies

3. UNIX for Dummies Questions & Answers

Is this possible with cronjobs?

Hi there, i've a question about cronjobs. I'm creating a concept for a centralized logging repository using log4j/log4net. Sadly the appenders I want to use (fileappenders) aren't telegram based but need a permanent stream to the repository. Because I can not assure this I want to log these... (6 Replies)
Discussion started by: collatz
6 Replies

4. Shell Programming and Scripting

Setting up cronjobs

hello all, I have a shell script and I need to schedule it in crontab, I have the next line: 06 16 * * 1,2,3,4,5 /usr/bin/ksh /path/path/name.sh > /path/path/name.log first, I scheduled from Monday to Friday but it doesn't run, the log file is empty.. any idea why is causing this?... (14 Replies)
Discussion started by: Geller
14 Replies

5. Shell Programming and Scripting

cronjobs stopped working

Hello people, I had these cronjobs scheduled in some Unix boxes which were running fine until yesterday.But then the password was changed for that user id and then the jobs stopped working. As far as i know cron jobs run from super user. I am completely lost over here now. Thanks. (2 Replies)
Discussion started by: King Nothing
2 Replies

6. Solaris

cronjobs not running.

hi friends, how to check if the cronjobs is not running and how to make it run again. (1 Reply)
Discussion started by: cromohawk
1 Replies

7. Linux

Cronjobs stopped working

Hi All, I am user of a Linux machine and I have approximatly 15 cronjobs scheduled in my crontab. Yesterday my administrator made LDAP active on my userid and all the things are doing fine after that. But all cronjobs for my user id stored in my crontab have stopped working after that. Could... (1 Reply)
Discussion started by: bisla.yogender
1 Replies

8. UNIX for Advanced & Expert Users

Delete Duplicate Cronjobs

I set up same cronjobs in two different users to generate messages at 5:30 AM Not Its generating duplicate messages. I want to delete the cron entries set up in the first user, but I am unable to view the entries in that user. I tried to find the process Id, but its not showing any id Could... (2 Replies)
Discussion started by: nskworld
2 Replies

9. AIX

Cronjobs

We recently upgrade from AIX 4.3.3 to AIX 5.3, We noticed that some cronjobs that run for our programmers did not fire off this morning. You can crontab -l and -e and see the jobs. Did AIX 5.3 change something? Thanks Mike (1 Reply)
Discussion started by: mcastill66
1 Replies

10. UNIX for Dummies Questions & Answers

cronjobs

hi How can I add a cronjob to the crontab file? to execute a shel script named testScript.sh every day at 00:00. Thanks (3 Replies)
Discussion started by: tamer
3 Replies
Login or Register to Ask a Question