- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to use crontab
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
11-24-2004 08:56 PM
11-24-2004 08:56 PM
Can you guys help me with this.. I would like to know what does the "2>&1" does in this line of cron job.
"
5 0 * * * $HOME/bin/daily.job >> HOME/tmp/out 2>&1 "
In addition, if I would like to run a program for every 2mins on my UX10.20b how do I do it?
should I used crontab -e to add the line? do I need to do anything thereafter?
thank u!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2004 09:02 PM
11-24-2004 09:02 PM
Re: How to use crontab
2>&1 to capture all output, then the redirection it to the appropriate destination.
58,02,06,10,14,18,22,26,30,34,38,42,46,50,54 * * * * /usr/local/www/bin/web_chechk >> /dev/null 2>&1
example above is used every 4 minutes.
Yes, use the crontab -e to edit the cron.
Regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2004 09:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2004 09:02 PM
11-24-2004 09:02 PM
Re: How to use crontab
1 is standard out
2 is standard error
>> $HOME/tmp/out redirects all the 'standard out' messages into /tmp/out file. 2>&1 tells the system to redirect all the error messages into 1 which is standard out which is inturn redirected to /tmp/out file.
If you want to run it every 2 mins, then it's slightly painful. Add the program like
0,2,4,6,8,10,12 (upto) 58 * * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
"crontab -e" is correct. It will open a 'vi' session. Once you make the changes, just save it and the changes will be automatically put into effect.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2004 09:05 PM
11-24-2004 09:05 PM
Re: How to use crontab
1. Errors will be redirected to Standard output that is your console.
2. 0,2,4,6,8,......,58 * * * *
Hope that helps.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2004 09:06 PM
11-24-2004 09:06 PM
Re: How to use crontab
To run a job every 2 minutes (assuming you start at minute zero
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * your_job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2004 09:07 PM
11-24-2004 09:07 PM
Re: How to use crontab
1>filename (or >filename without 1) redirects standard output (stdout).
&2 means stderr. &1 means stdout. So 2>&1 redirects stderr to the same file than stdout (output will be mixed).
To run a job every two minutes, you need something like that :
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * myjob
(which may be a little annoying. More recent crons such as Linux one, implements something like 0/2 that means every 2 minutes starting at 0. But we have to wait for HP to implement this feature)
for more explenations use "man crontab"
crontab -e is enough. No need to do extra things. Once saved, new crontab replaces old one.
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2004 04:28 PM
11-25-2004 04:28 PM
Re: How to use crontab
Just so you know for reference
> implies redirection to a file
x>&y means take the CURRENT place y is pointing and redirect x to it. So this implies the following ...
command >> HOME/tmp/out 2>&1
and
command 2>&1 >> HOME/tmp/out
would yield different results.
Unix standard files is the following
0 = stdin
1 = stdout ( if none is specified this is the default with redirection). Hence the following.
command >> HOME/tmp/out 2>&1
and
command 1>> HOME/tmp/out 2>&1
is equivalent.
2 = stderr
HTH
Gerhard