- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Cron Question
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
02-03-2005 08:41 AM
02-03-2005 08:41 AM
Cron Question
Run "/scripts/backup" every last friday of the month at 6:00am ??
Thanks,
f.halili
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 08:59 AM
02-03-2005 08:59 AM
Re: Cron Question
What you should do is run a script every friday and use caljs.sh, an A. Clay Stepenson invention to determine if it is ineed the last friday of the month and go forward with the backup.
Shell version:
http://www.hpux.ws/merijn/caljd-2.23.sh
Perl version
http://www.hpux.ws/merijn/caljd-2.2.pl
crontab entry:
* * * * 5 /command
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 09:07 AM
02-03-2005 09:07 AM
Re: Cron Question
Put each one on a different line (12 lines in all)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 09:30 AM
02-03-2005 09:30 AM
Re: Cron Question
#!/usr/bin/sh
export PATH=${PATH}:/usr/local/bin
if [[ $(caljd.sh -M) != $(caljd.sh -n 7 -M) ]]
then
echo "Do your thing; it's the last Friday"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 08:20 PM
02-03-2005 08:20 PM
Re: Cron Question
#crontab -e
# Minute Hour MonthDay Month Weekday Command
# ----------------------------------------------------------
0 06 * * 5 /sbin/sh your_path/script
Notes: 0=Sunday, 1=Mon ...5 =Friday
tienna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 11:17 PM
02-03-2005 11:17 PM
Re: Cron Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2005 11:36 PM
02-03-2005 11:36 PM
Re: Cron Question
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:33 AM
02-04-2005 01:33 AM
Re: Cron Question
If you could live with the 4th Friday every month instead of the last Friday, you could do:
0 06 21-28 * 5 /scripts_dir/backup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:56 AM
02-04-2005 01:56 AM
Re: Cron Question
0 06 21-28 * 5 /scripts_dir/backup
will certainly run on the last Friday of the month but sadly it will also run on every other Friday of the month as well. In addition, it will also execute the command every doy of the month from the 21st to the 28th. When weekdays and monthdays are specified in cron, the result is not a logical AND but is rather a logical OR.
Use the solution I suggested earlier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 01:57 AM
02-04-2005 01:57 AM
Re: Cron Question
DO a minus on this day and see what is the day..using some date format, if the day turns out to be friday, you can execute the command..
date would be 31,30,28
do 31 - 5,4,3,2,1,0...see what it returns..execute ur script if it is friday...
you can divide the script in 3parts probably..and call from a small script in cron..
Hope it helps
Thanks and regards
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 03:06 AM
02-04-2005 03:06 AM
Re: Cron Question
Crontab (starts custom script every friday) :
0 6 * * 5 /scripts/backup_start
Script
#!/usr/bin/ksh
Last_day_in_month=`cal | sed '/^$/d' | tail -1 | head -1 | awk '{print $NF}'`
Today=`date +%d`
if [ `expr $Today + 7` \=> `expr $Last_day_in_month` ]
then
fi
Regards,
Sergejs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2005 08:01 AM
02-04-2005 08:01 AM
Re: Cron Question
# Check if day is Fri
today=$(date +%a)
if [ "$today" != "Fri" ]
then
echo "Okay, will not run now since today is $today and not Fri."
exit
fi
00 06 25-31 1,3,5,7,8,10,12 * /scripts/backup
00 06 24-30 4,6,9,11 * /scripts/backup
00 06 22-28 2 * /scripts/backup
This would still require a method to deal with February when it has 29 days with the 29th on a Friday.
Switching to the first Friday of the month let's you just run the script on days 1 through 7.
Marlou
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2005 01:54 PM
02-06-2005 01:54 PM
Re: Cron Question
I think Clay's solution is the simplest and you can be sure that it will run on the last Friday of the month. Why complicate it, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2005 08:18 AM
02-07-2005 08:18 AM