The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What can make Cronjobs stop working?? Nintendo UNIX for Dummies Questions & Answers 0 06-04-2008 02:40 PM
Delete Duplicate Cronjobs nskworld UNIX for Advanced & Expert Users 2 07-20-2007 10:30 AM
Time Zone in AIX and cronjobs run_time_error AIX 1 04-28-2006 06:42 AM
Cronjobs mcastill66 AIX 1 05-31-2005 02:15 PM
cronjobs tamer UNIX for Dummies Questions & Answers 3 01-22-2001 02:48 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-05-2008
krworks krworks is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 4
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 (permalink)  
Old 06-06-2008
incredible incredible is offline Forum Advisor  
Registered User
  
 

Join Date: May 2008
Location: s'pore
Posts: 2,024
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 (permalink)  
Old 06-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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 (permalink)  
Old 06-06-2008
incredible incredible is offline Forum Advisor  
Registered User
  
 

Join Date: May 2008
Location: s'pore
Posts: 2,024
I was just showing an example of cron entry. Anyway, he should not have any problems running all the crons at one go
  #5 (permalink)  
Old 06-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0