- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- CRON Setup
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
04-18-2001 11:17 AM
04-18-2001 11:17 AM
I need to setup two new jobs in CRON.
1. To run every Sat. night at 8:45 to
execute /filename/script.sh
2. 4am Sunday morning to 8:30pm Saturday nite
to execute at 5 mins intervals. To execute the
file below every 5 mins. in the range above.
/filename/script2.sh
How would I enter this in cron?
Review on how to set this up...It's been a while and the last time I setup cron, I load
it several times and caused problems.
TIA,
Laurie Krumrey (formerly Laurie Brown)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 11:28 AM
04-18-2001 11:28 AM
SolutionYour crontab entries would look as follows:
45 20 * * 6 /filename/script.sh
0,5,10,15,20,25,30,35,40,45,50,55 4-20 * * 0-6 /filename/script2.sh
Use 'crontab -e' while logged in as the appropriate user to put these entries into that users crontab file. Do a 'crontab -l' to list crontab entries.
The syntax of a line in cron is:
minute hour day-of-month month day-of-week command to run
Any field with a * in it will run for all values of that field (every minute, every hour, every day of month, every month, every day of the week). The days of the week are specified as 0-6 where 0=Sunday, 1=Monday, etc. The hour is specified as 24 hour time. Do a 'man crontab' for more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 11:36 AM
04-18-2001 11:36 AM
Re: CRON Setup
insert
45 8 * * 6 /filename/script.sh
00,05,10,15,20,25,30,35,40,45,50,55 * * * 1-5 /filename/script2.sh
00,05,10,15,20,25,30,35,40,45,50,55 00-19 * * 6 /filename/script2.sh
00,05,10,15,20,25,30,35,40,45,50,55 04-23 * * 0 /filename/script2.sh
Should do it.
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 11:37 AM
04-18-2001 11:37 AM
Re: CRON Setup
What I had would go every 5 minutes from 4 AM to 8PM every day of the week. If I read correctly what you need is every 5 minutes 24 hours a day from 4AM Sunday to 8:30 PM Saturday. To do that you would need to do the following:
#The following will run the script every 5 minutes from 4:00AM till 23:55 PM Sunday
0,5,10,15,20,25,30,35,40,45,50,55 4-23 * * 0 /file/script2.sh
#The following will run the script every 5 minutes 24 Hours a day Monday - Friday
0,5,10,15,20,25,30,35,40,45,50,55 * * * 1-5 /file/script2.sh
#The following will run the script every 5 mintes from Midnight till 19:55 Saturday
0,5,10,15,20,25,30,35,40,45,50,55 0-19 * * 6 /file/script2.sh
# The following will run the script every 5 minutes from 20:00 till 20:30 Saturday
0,5,10,15,20,25,30 20 * * 6 /file/script2.sh
Unfortunately this is the only way I can think of to run the script with your time requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 11:39 AM
04-18-2001 11:39 AM
Re: CRON Setup
as root:
1. crontab -l > /tmp/root
2. vi /tmp/root & enter the following
45 20 * * 6 /filename/script.sh
3. Save file & crontab < /tmp/root
4. Check your work with crontab -l
Case 2 is a bit more tedious:
Same crontab & vi steps as above with these
entries:
# To take care of Mon-Fri
0,5,10,15,20,25,30,35,40,45,50,55 * * 1-5 /filename/script2.sh
# Sun
0,5,10,15,20,25,30,35,40,45,50,55 4-23 * * 0 /filename/script2.sh
# Sat
0,5,10,15,20,25,30,35,40,45,50,55 4-23 * * 6 /filename/script2.sh
0,5,10,15,20,25,30 20 * * 6 /filename/script2.sh
That should do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 11:42 AM
04-18-2001 11:42 AM
Re: CRON Setup
also:
0,5,10,15,20,25,30 20 * * 6 /filename/script2.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 11:54 AM
04-18-2001 11:54 AM
Re: CRON Setup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 12:32 PM
04-18-2001 12:32 PM
Re: CRON Setup
However..I don't want cron sending email
every 5 minutes to root...Can I tell it
only to send email if there is a problem and
not to sent email other wise?
Here's what I get in root's email:
ubject: cron
Status: R
running
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
/usr/ops/autotree/scripts/file.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2001 12:43 PM
04-18-2001 12:43 PM
Re: CRON Setup
If you are confident that your command(s) alway(s) succeeds:
Within your script:
my_cmd > /dev/null 2>>/dev/null
to redirect both stdout & stderr to /dev/null
or
Something like this:
TFILE1=/var/tmp/X$$_1.txt
my_cmd > ${TFILE1} 2>>${TFILE1}
STAT=$?
if [ ${STAT} -ne 0 -a -s $TFILE1 ]
then
cat $TFILE1
fi
rm -f $TFILE1
If the exit status of my_cmd is non-zero,
then the stdout & stderr of my_cmd is echoed
and picked up by mail from cron
You would need to do this for each separate command in your script that you desire to monitor for error or wrapper the whole thing.