Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute on a date parameter file.

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Hello All,

I have a job (my_job) to be executed in crontab. I only want my_job to be executed at certain non-uniform dates. So I think the best way is to have a shell script wrapper around the job. So that I can pass my date file as parameter.

The parameter file will be like:
20091124
20091130
20091210
20100103
....
....
20101109

1) I will set up the job to run every day at say 10:00pm in crontab
2) Once the job starts, first thing to do will be to fetch the date paremeter file, go through each line see if the date is equal to today's date, if so execute and send an email to me that it executes my_job. If not the date is not equal to today's date exit.

Question: Does anyone have a script that could do line item 2) ?

Thanks for your prompt reponse everyone, much apreciated.

Tekpr00
 
Something like this at the beginning of the script should do it.

Code:
grep -qx $(date +%Y%m%d) /path/to/datefile || exit


Annihilannic.
 
THis is what I ended up using:
#!/usr/bin/ksh
#
sys_date=`date +'%Y%m%d'`
for ref_date in $(< date_parmfile.txt); do
if (($ref_date != $sys_date)); then
: # do nothing
else
echo "$ref_date"
fi
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top