Cronjob on alternate sundays


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cronjob on alternate sundays
# 1  
Old 03-23-2005
Cronjob on alternate sundays

I want to set the crontab job for one of my SIEBEL database to refresh it on alternate sundays. Is there anyway I can do it through cron please ?
If not whats the alternative ? Smilie

Thanks in advance.
# 2  
Old 03-23-2005
You can run it every Sunday through cron and then put some logic into the script you are running to check if it's a alternate Sunday or not (as easy as creating a file after your last good run to touch a file (create the file) if it's not there or to delete it if it is there.

Sunday 1 -check for file - not there then run job - touch file
Sunday 2 -check for file - there - remove file - end
Sunday 3 - check for file - not there then run job - touch file
Sunday 4 - check for file - there - remove file - end
# 3  
Old 03-23-2005
My datecalc script can calculate a day number when given a date. And it can also calculate a day-or-week number much like cron uses. With a little algebraic legerdemain it is possible to use those numbers to classify weeks into two sets "even" and "odd" without any need for a state file. I have extended my weekselector script to do this. So using weekselector is now another option.

weekselector
# 4  
Old 03-24-2005
Not tested...

5 4 * * sun (($(/usr/bin/date +%W)%2)) && echo "run at 5 after 4 every other sunday - odd weeks"
5 4 * * sun (($(/usr/bin/date +%W)%2)) || echo "run at 5 after 4 every other sunday - even weeks"
# 5  
Old 03-24-2005
There's a couple of problems there, Ygor. A % in a crontab entry will not work as expected. This nailed me too. See that weekselector thread for details. Also, I'm not sure that this will work across the year to year transitions for all years. I screwed up my system changing dates, so I'm not going to keep looking for a counter-example. (But for the 2 years that I did check, it did seem to work.) And that syntax requires a modern shell. Some systems still have a old Bourne shell processing crontab entries.
# 6  
Old 05-06-2005
i have run the script as RTM suggested..so my script looks like this:
-------------------------------------------
if [ -f /filename ]
then
rm filename;
do job1;

else
touch filename;
do job2;
job3;
fi
-------------------------------------------

and I am calling this script on each monday. The prob still is everymonday the scirpt goes thru job1, job2 and job3. why does it do so ?
# 7  
Old 05-06-2005
hello,
i am new in solaris system administrations please i need to get informations on how to create new account on a solaris system, i have tried creating using the useradd command but have not been successfull, pls help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add previous Sundays date to filename

I am looking for some scripting help. I need to add a time stamp to a file name. I will append data to a file, and want to add to the file name a time stamp of the previous Sundays date. Any takers? (1 Reply)
Discussion started by: sswagner8839
1 Replies

2. Shell Programming and Scripting

Taking the count of sundays between two date ?

Hi Am using unix Ksh Datecalc and --date functions are not working have two input variables as DATE=01/12/2012 DATE1=23/12/2012 Need output as no of sundays = 4 Can anyone help me pls :( (2 Replies)
Discussion started by: Venkatesh1
2 Replies

3. UNIX for Advanced & Expert Users

How to take the count of all sundays between two dates?

Hi Am Using Unix Ksh I have input DATE1=01/11/2012 DATE2=10/12/2012 need output as count of all sundays between these two dates for examples Sunday count between DATE1 and DATE2 is 5 Can anyone help me... (11 Replies)
Discussion started by: Venkatesh1
11 Replies

4. HP-UX

Alternate for wget

Hi, Whats the alternate for wget in HP-UX ? (4 Replies)
Discussion started by: mohtashims
4 Replies

5. UNIX for Dummies Questions & Answers

Listing out sundays alone

I am trying to list out only sundays from december 2011. pandeeswaran@ubuntu:~/training$ cal 12 2011|sed -n '3,$p'|sed -e'/^$/d'|awk '{ORS=",";print $1}' 1,4,11,18,25,,pandeeswaran@ubuntu:~/training$ Can anyone help me? Thanks (13 Replies)
Discussion started by: pandeesh
13 Replies

6. UNIX Desktop Questions & Answers

count of sundays in month

Hi, How to get count of number of sundays in month in unix shell script .. ideally i need 2 get last sunday of month so i used cmd: for eg: for june: cal 06 2011 | tail -2 | head -1 | cut -d" " -f1 hoowever above is wrking for month whose sundays are max=4 but not fr months... (4 Replies)
Discussion started by: musu
4 Replies

7. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

8. Shell Programming and Scripting

alternate lines

Hi, I'm new to Unix. I want to read the all the lines from a text file and write the alternate lines into another file. Please give me a shell script solution. file1 ----- one two three four five six seven newfile(it should contain the alternate lines from the file1) ------- one... (6 Replies)
Discussion started by: pstanand
6 Replies

9. Shell Programming and Scripting

Alternate way for echo.

Hi, Is there any other command echo does. if I am doing this operation for each line in my file. So its taking very long time to process more than 1000 records. Is there any alternative way to write the above if statement (5 Replies)
Discussion started by: senthil_is
5 Replies

10. Shell Programming and Scripting

List of Sundays for the years 2000 to 2005

hi, i need to write a script that would list me all sundays in the year 2000 and 2005. output need to be just the date . ;) (1 Reply)
Discussion started by: kquest
1 Replies
Login or Register to Ask a Question