1828245 Members
2626 Online
109975 Solutions
New Discussion

Schedule file

 
la_cool
Occasional Advisor

Schedule file

I have a process script which needs to run every "other Thursday,Friday", I need to schedule the job .

Please share your thoughts, idea ..
5 REPLIES 5
RAC_1
Honored Contributor

Re: Schedule file

Search the forum for date hammer.
This utility is by A Clay.

This is how to go about your cron entry.

The script will run every thursday and friday. Will update a status file with date. Nest thursday/friday, it will check when was it run last time and if time difference is 14 days, execute it, else not.

This is the logic, I would recommand you to use. And will require some good scripting to be done. But it will be a lot easier with the caljd.sh(date hammer)

Anil
There is no substitute to HARDWORK
Steven E. Protter
Exalted Contributor

Re: Schedule file

Its called cron

The sysadmin's servert/slave/lackey

crontab -l

displays the current schedule

crontab -e lets you edit it

http://search.hp.com/redirect.html?url=http%3A//forums1.itrc.hp.com/service/forums/questionanswer.do%3FthreadId%3D137999&qt=cron+%2Bconfiguration&hit=4

If you are actually working on a server and not studying for a test, I recommend HP's Sysadmin I course.

http://docs.hp.com/hpux/pdf/B2355-90781docs.pdf

SEP


Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
la_cool
Occasional Advisor

Re: Schedule file

Hi,

I'm looking for the script that can run every other Thursday and friday.

I 'd like to know how do I set in the "cronjob or at command".
A. Clay Stephenson
Acclaimed Contributor

Re: Schedule file

You CAN'T simply use cron; it's not that smart but what you can do is run a command EVERY Thursday and Friday and then let the command itself figure out if this is an even or odd week and run only on the even weeks otherwise it simply exits. Note: Cron has an intentionally sparse environment including PATH so generally the first thing a script has to do is set and export PATH:

You need to download and install the attached caljd.sh script; among other things, it can return the number of days since Jan 1, 4712 BCE; divide that number by 7 and you get a week number; mod that by 2 and you get 0 or 1. Invoke as caljd.sh -u for full usage and examples.

Your crontab entry should look like this:

0 6 * * * 4,5 /root/bin/myscript.sh

Run at 0600 each Thursday and Friday.

Your myscript.sh should look something like this (assuming that you have insatlled caljd.sh in /usr/local/bin):

#!/usr/bin/sh

export PATH=${PATH}:/usr/bin:/use/local/bin
STAT=0
if [[ $(( (($(caljd.sh) - 1) / 7) % 2 )) -eq 0 ]]
then
echo "Do your thing"
fi
exit ${STAT}

Note the "$(caljd.sh) - 1" that is done because Julian Day 1 fell on a Monday and weeks are generally considered to start on Sunday. You may want to change the "-eq 0" to
"-eq 1" depending on which week you actually want to start. Unlike using the week number from the date command, caljd.sh will continue to work whether or not the year has 52 or 53 weeks (or parts thereof) in it.
If it ain't broke, I can fix that.
YoungHwan, Ko
Valued Contributor

Re: Schedule file

You can do this using sam.

# sam -> Process Management -> Scheduled Cron Jobs -> Action -> Add

This is easy way to set scheduling job.