Crontab running every alternative sunday


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Crontab running every alternative sunday
# 1  
Old 03-23-2010
Crontab running every alternative sunday

Hi,

I want to run a script starting this 28 Mar 2010 every alternative sunday. Can you give me the crontab entry for the same. Mine is a HP unix.
# 2  
Old 03-23-2010
many solutions...
Giving you 2 here
1)using any variant of dummy file e.g.
the crontab file runs every sundays.
Since this sunday will be the first and you want it to run:
You job tests presence of dummy file ( not there yet)
no dummy file, so execute the job -and creates the dummy file
the next sunday, if dummy file present (should be the case...), no execution but removes dummy file.
and so on...
2) a self scheduling at job (with at now + 14 days)
# 3  
Old 03-23-2010
You could call a cron script every Sunday, and then use the modulus operator against the julian date to determine if its an odd, or even week, and run you commands depending on that result.

Code:
#!/usr/bin/bash

function doit {

  echo running cron entry
  # enter commands you want to run in this function #
}

JDATE=`date +%j | sed 's/^0//'`

RUNN=$(( $JDATE % 2 ))

[[ $RUNN -eq 0 ]] && doit || echo waiting until next week

Notes:
sed command is there to strip leading zero, which would be an issue.
If you want to run on even weeks, leave "-eq 0", or if you want to run on odd weeks
change it to "-eq 1"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Crontab running bi-weekly

Hi experts, Need your help to schedule the script(test.sh) bi-weekly in linux machine. script need to run at every alernate thursday at 9 am . Please help to run the same. (6 Replies)
Discussion started by: abhigrkist
6 Replies

2. UNIX for Dummies Questions & Answers

crontab not running script

Hi All, I am having the below script to be run from crontab, it it doesnt run. 1 * * * * /home/cobr_ext/test.sh > /home/cobr_ext/temp.txt when i run i manally it runs without any issues. Could please help me as to why doesnt it run the script.:( (7 Replies)
Discussion started by: abhi_123
7 Replies

3. Solaris

Cronjob doesnot exist on the machine but running every sunday

I have deleted a particular cronjob couple of months ago but the jb is still running every sunday, even though it is not present in /var/spool/cron/crontabs/root file. Please assist. (6 Replies)
Discussion started by: prash358
6 Replies

4. UNIX for Dummies Questions & Answers

Issue while running from crontab

Hi All, Here is my command which I've scheduled to be run from crontab, but it's giving error message: rah: rahhost executable needed but not in PATH My cmd is- 36 10 * * * /opt/IBM/dwe/db2/V9.5/bin/rah "df -m" >> /db2home/bculinux/Files/log/db.out 2>&1 Though I've added path... (5 Replies)
Discussion started by: NARESH1302
5 Replies

5. Shell Programming and Scripting

Crontab not running a script

Hi, I posted this in the Solaris forum but I think this one would be more appropriate. I created a script starting with the following lines: #!/usr/bin/ksh flag=n export flag typeset -i quant=0 (...) When running it I'm getting the following 2 errors: /tmp/tstscript/testfail.ksh:... (9 Replies)
Discussion started by: Cvg
9 Replies

6. UNIX for Dummies Questions & Answers

crontab job not running

Hi all, down here part of the scheduled job in crontab (AIX Version 5) i have problem running jspPRE-ALL. i verrify permissions and privileges (the others job are working good) if i run the job in command line it work correctly # # Aggiornamento doni e continuity 00 02 * * 2-6... (5 Replies)
Discussion started by: ilpasta
5 Replies

7. UNIX for Advanced & Expert Users

Crontab is not running!!!

Hi experts, need your helpo. after editing the crontab while saving the file it says- "/tmp/crontabRlaauT" 1 line, 77 characters cron may not be running - call your system administrator And i checked after certain time. script in cron is not running. I got a mail in user saying... (1 Reply)
Discussion started by: thepurple
1 Replies

8. Shell Programming and Scripting

Crontab job to run every sunday

Hello, I wanted to run one of my shell script for every sunday at 5PM. Here is the crontab entry i am using.. 00 17 * * 0 /inventory/update.sh > /inventory/update.log 2>&1 The job is not kicking on sunday at the specified time.. Am i missing anthing? Any help is appreciated... (2 Replies)
Discussion started by: govindts
2 Replies

9. AIX

Crontab job on sunday with two week interval

Hi experts, Please help me to set a backup script run at 6AM on Sunday every two week It means the 1st sunday, run script backup at 6AM the 2nd sunday, skip the 3rd sunday, run script backup at 6AM the 4nd sunday, skip ... so on Thank you so much (4 Replies)
Discussion started by: tan.pham
4 Replies

10. UNIX for Dummies Questions & Answers

running sql in crontab

Hi, i have a scripts that update an SQL DATABASE using sqlplus command. when i run it in a interactive mode its ok but when try to run it using the crontab i get an a messege : "Must be attached to terminal for 'am I' option" (there is no "who am i" command in the script) and the DB... (4 Replies)
Discussion started by: dorilevy
4 Replies
Login or Register to Ask a Question