- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Who can help me about how to use "crontab" command
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-05-2002 06:26 PM
02-05-2002 06:26 PM
#M H D M Y CMD
15 * * * * echo 'Woohoo, spring is here!'
My question is :
This job need be run four times at each hour, who can help me how to write the crontab file?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 06:32 PM
02-05-2002 06:32 PM
Re: Who can help me about how to use "crontab" command
All you need to do is place a comma after each
entry for the minutes.
For example you wanted to run a job at 15
minute intervals, at 1 minute past the hour
and again at 16 31 and 46 this is all you do.
1,16,31,46 * * * * /usr/local/bin/myjob
HTH
-Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 06:51 PM
02-05-2002 06:51 PM
Re: Who can help me about how to use "crontab" command
You can indicate the time you want in the all the field of time, eg.
If I want to run a job (in crontab) 4 times an hour, 4 times a day, I can specify that like this:
0,15,30,45 09,12,15,18 * * *
Hope this helps.
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 06:53 PM
02-05-2002 06:53 PM
Re: Who can help me about how to use "crontab" command
One further thought. To edit your crontab
correctly use this example, as root.
# crontab -l >/tmp/wrk1
Make your changes and save the file
# crontab /tmp/wrk1
Never use crontab -e as it is a recipe for
disaster.
Use the man pages as a further guide.
man cron (explanations of the minutes, hours etc.
man crontab
HTH
-Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 07:19 PM
02-05-2002 07:19 PM
Re: Who can help me about how to use "crontab" command
A point to note: cron jobs are not associated with any particular terminal. Cron is normally used for non-interactive, background processes.
So don't be surprised if you don't see 'Woohoo, spring is here!' on your screen every 15 minutes. You will have more luck if you redirect the output like so - echo 'Woohoo, spring is here!' >> /tmp/cron_output

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 08:30 PM
02-05-2002 08:30 PM
Re: Who can help me about how to use "crontab" command
However, if i want to run my job each three mintues, has some more good method? Can it be use like it: ( of course it is not right in HP-UX, this is only an idea )
#M H D M Y CMD
*/3 * * * * date
In fact, I need more complex. My job is first start at 18 mintue, then need start after each 15 mintue later.
I need your more help.
Thanx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 08:46 PM
02-05-2002 08:46 PM
Re: Who can help me about how to use "crontab" command
You can start the job as many times as you wish.
All you need to is to place a comma after each
minute entry. You can run the same job every
minute if you wish.
e.g. A job every 3 minutes
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/local/bin/myjob
HTH
-Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2002 08:56 PM
02-05-2002 08:56 PM
Solution>> In fact, I need more complex. My job is first start at 18 mintue, then need start after each 15 mintue later.
Instead of using cron, you can use a nohup script job in the background:
# nohup my_job &
In your my_job script,
=====================================
#!/sbin/sh
# This will wait for 18 mins before running the initial task perform_initial_task.
sleep `expr 18 \* 60`
perform_initial_task
# This will wait for 15 mins from the completion endtime of perform_initial_task before running perform_periodic_task which proceeds to run every 15 mins (from the completion endtime of the last execution).
while sleep `expr 15 \* 60`
do
perform_periodic_task
done
=====================================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2002 08:29 PM
02-06-2002 08:29 PM
Re: Who can help me about how to use "crontab" command
thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2002 08:49 PM
02-06-2002 08:49 PM
Re: Who can help me about how to use "crontab" command
perform_initial_task
counter=1
while [ $counter -le 40 ] # stop in 10 hours
do
sleep `expr 15 \* 60`
perform_periodic_task
(( counter = counter + 1 ))
done
If you want to start the job at 9:18am daily, you can use crontab job:
18 09 * * * script
No need to give points to me, I just get this from Steven's reply.
Regards,
Kenny.