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 > Operating Systems > SUN Solaris
.
google unix.com



SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scheduling bi-weekly through cron LPT UNIX for Advanced & Expert Users 5 02-20-2009 11:45 AM
cron scheduling? megh HP-UX 1 08-19-2008 02:27 PM
Problem with scheduling a shell script on cygwin using cron shash UNIX for Dummies Questions & Answers 4 08-09-2007 06:08 PM
scheduling tasks with cron alikun UNIX for Dummies Questions & Answers 4 03-21-2007 04:32 PM
cron job scheduling shihabvk UNIX for Advanced & Expert Users 1 08-22-2005 10:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2008
kumarmani kumarmani is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 343
Cron job scheduling on the alternate day of the week

Hi,

Help please!

I have to schedule some job on every Monday and alternate Thursday with Cron. I am not sure as if I pass 1 and 5 on the day filed, the job will be scheduled for every Monday and Thursday. How to schedule in job in above case.

Thanks in anticipation.
  #2 (permalink)  
Old 09-29-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,305
Have a read of this link regarding this stuff:

cron and crontab

Regards
  #3 (permalink)  
Old 09-29-2008
kumarmani kumarmani is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 343
Hi Frank

Thanks for the link!

However my problem is still open.

From the given link
---------------------------
0 0 1-7 * 5 /some/script
You might hope that will run /some/script during the first minute of the first Friday of the month. Unfortunately, it will run the script on each day of the first week of the month and on every Friday.
----------------------

In my case I have to schedule the job on every Monday and every alternate Thursday. If the write the below code

0 0 1-7 * 1,4 <path to script>

Then above will run every Monday and Thursday, however I have to skip one week and then run the script in case of Thursday.

Please help !

Regards
  #4 (permalink)  
Old 09-29-2008
wempy's Avatar
wempy wempy is offline
Registered User
  
 

Join Date: Jun 2006
Location: Harpenden, UK
Posts: 208
A simple, though not particularly elegant, solution, is to write a wrapper script that executes your target script on the specified days, and call the wrapper script from cron.

eg (of the top of my head, not tested):
Code:
#!/bin/bash
FLAGFILE=/var/tmp/FlagFileNameThatIsUnique
DAY=`date +\%a`
case $DAY in
Mon) /path/to/script/to/be/run;;
Thu) [ -f $FLAGFILE ] && rm $FLAGFILE || (/path/to/script/to/be/run; touch $FLAGFILE);;
esac
set the cron entry to call the wrapper every monday and thursday.
The wrapper will only run the script on a thursday if the flagfile doesn't exist (and create the flagfile, once it has run). The next time it gets called on a thursday the flagfile will exist, so it doesn't run the script, just deletes the flagfile.

You may want to be careful where you store the flagfile, as on your system /tmp and /var/tmp may be 'cleaned' if the system is rebooted. You also have to ensure that the flagfile is uniquely named, so that nothing else can interfere with it.
  #5 (permalink)  
Old 09-29-2008
kumarmani kumarmani is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 343
Thanks Wempy

Are we saying without having a wrapper script it’s not possible to schedule the script on alternate days of the week?
  #6 (permalink)  
Old 09-29-2008
wempy's Avatar
wempy wempy is offline
Registered User
  
 

Join Date: Jun 2006
Location: Harpenden, UK
Posts: 208
well, it is possible, but your crontab lines get awfully long. Cron will only execute EVERY set day, there is no explicit way to tell it every Other set day, so you have to test whether it should run today or not, and in the simple, binary, case like this, the easiest (maybe quickest) solution is to keep track of things with a flagfile.
You can put the logic in the wrapper script above into the cron entry, but, as I said, it makes the entry very long, and difficult to read.
  #7 (permalink)  
Old 09-29-2008
kumarmani kumarmani is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 343
I appreciate you help!

Please can you let me know what will be the entry in crontab evne though its big I would like to test it.

Thanks again
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 11:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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