- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scheduling cron job
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 11:26 AM
07-27-2001 11:26 AM
scheduling cron job
Thanx in advance for any help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 11:35 AM
07-27-2001 11:35 AM
Re: scheduling cron job
You can do this in your script. If you running any program then call that prgram from script.
Now run your program from cron for all sat. and it will run only on even sat.
set WEEK = `date +%U`
@ ALTWK = $WEEK % 2
switch ($ALTWK)
case 0:
set SET = 1
breaksw
case 1:
set SET = 2
breaksw
endsw
if ( $SET == 1 )
call program;
else
exit 0;
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 12:29 PM
07-27-2001 12:29 PM
Re: scheduling cron job
If I understand you , you want not that the script run in 1st and 15th saturday of the year, correct ??
If I correct, you will can to note every
saturdays of the year and put it in the cron
line. For exmple this month ( July ) have a
four saturdays ( 7 14 21 28 ) then you crontab line will stay, for example, as below :
0 4 14,21,28,.....* * /dir/comand
The crontab will execute the more restrictive comand, in this case, it ignored the * * and
run only in the days that was specify.
I hope this help.
Regards,
Abel Berger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2001 01:20 PM
07-27-2001 01:20 PM
Re: scheduling cron job
Another way to do it is to put it into a script that uses 'at' to reschedule itself each time it runs.
You could have a script named 'myscript' that looks like this:
#!/bin/sh
# myscript
# Start of script
.
.
# End of script
echo "sh /home/users/myhome/myscript" | at 1900 saturday next +3 weeks
The next parameter in 'at' defaults to 'next +1', so to get it set two weeks out you would do 'next +3'.
Just another way to do it.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2001 02:02 PM
07-30-2001 02:02 PM
Re: scheduling cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2001 02:17 PM
07-30-2001 02:17 PM
Re: scheduling cron job
if .RUN then
process
mv .RUN .SKIP
exit
else
mv .SKIP .RUN
fi
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2001 02:27 PM
07-30-2001 02:27 PM
Re: scheduling cron job
I think I have the perfect way to do this and it uses a technique that I have used for many years. Use the attached script to return a Julian Day (~ No. of days since 01/01/4712 BCE - Astronomers use a variant of this to make calculations simple).
You then divide this by 7 to get get the week number. Mod this by 2 and you get either 1 or 0. The advantage of this, is that it truly does work every other week. The %U format operator in date sometimes does not work as expected because some years have 53 weeks and most have 52.
Your cron entry should of course fire off each Saturday and then call a script something like this: (caljd.sh is the attached script)
#!/usr/bin/sh
JDAY=`/usr/local/bin/caljd.sh`
JWK=$((${JDAY} / 7))
IS_WK=$((JWK} % 2))
if [ ${IS_WK} -eq 1 ]
then
echo "Do your Stuff Goes here"
else
echo "Do nothing"
fi
This will absolutely work, year in, year out.
Depending on your application, you might actually fire off your application on 0 rather than 1 but you get the idea.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2003 07:35 AM
02-04-2003 07:35 AM
Re: scheduling cron job
I've been using your method for months to automate a job I have to run on alternate tuesdays.. Today it failed.
It ran as usual on 1/7 and 1/21 but didn't fire off the job today 2/4/03.. ?
Any ideas why?
thanks so much!
John Henrikson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2003 07:49 AM
02-04-2003 07:49 AM
Re: scheduling cron job
Use this version and all should be well. In the comments sectiopn, I indicate my dumb error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2003 07:52 AM
02-04-2003 07:52 AM
Re: scheduling cron job
John Henrikson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2003 07:58 AM
02-04-2003 07:58 AM
Re: scheduling cron job
0 0 * * * 6 /usr/local/bin/run_every_two_weeks
---------------
#!/bin/ksh
## Run every_two_weeks_script
# Get current weeknumber
week=`cat /usr/local/etc/week_number`
# Only for the first time when $week is not yet set :
if [ -z $week ]
then
week="0"
fi
if [ $week -eq "1" ]
then
/run/this/script
echo "0" >/usr/local/etc/week_number
else
echo "1" >/usr/local/etc/week_number
fi
# ---------------------------
Regs David