- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- configuring 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
02-05-2006 06:34 AM
02-05-2006 06:34 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 06:58 AM
02-05-2006 06:58 AM
Re: configuring cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 07:07 AM
02-05-2006 07:07 AM
Re: configuring cron job
The main problem when you write a script, which should run in crontab is environment, mainly PATH. When a script runs from crontab, it's PATH contains /bin and /usr/bin. Because of that, all commands should be used with their full path. In order to simplyfy the problem, put in the beginning of the script
. ~/.profile
or to create a file which contains all needed variables and download it.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 07:08 AM
02-05-2006 07:08 AM
SolutionFirst, read the manpages for 'crontab(1)'. This is really quite explanatory.
Make sure that your login is allowed in '/var/adm/cron/cron.allow'.
Personally I prefer to write any current crontab to a file; edit that file; and lastly replace the current crontab file with the editted one. Others will use the direct edit option of 'crontab' using '-e'.
Thus, method-1 is:
# crontab -l > $HOME/crontab
[ edit $HOME/crontab ]
# crontab $HOME/crontab
Method-2 is:
# crontab -e
Method-2 simply invokes 'vi' using a temporary version of your crontab file (under the account you are logged into, of course). When you write/quit the editted version, your crontab is replaced.
My preference in using method-1 is that I mangle the editting in any way, I can simply discard the file, or write (save) what I have and fix it again before I apply it.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 07:58 AM
02-05-2006 07:58 AM
Re: configuring cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 08:21 AM
02-05-2006 08:21 AM
Re: configuring cron job
25 02 * * * $HOME/tulip/sh
...where "*" means "every" and the fields are:
minute hour monthday month weekday command
Shiv, I encourge you to use the manpages as a resource. They are meant to be reference material and do assume some knowledge, *but* the more you read them, the more comfortable you will become with trying to read them. Usually you will find examples in the discussion which can be related easily to the initial synopsis (syntax).
The structure of the HP-UX manpages is described here (below). As a user and as an administrator, you will spend most of your time in sections 1 and 1M. A great deal of information on configuration files appears in section-4. Section-9 has a very good glossary.
http://www.docs.hp.com/en/B2355-60127/Introduction.9.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 02:41 PM
02-05-2006 02:41 PM
Re: configuring cron job
25 02 * * * Full path to script 1>/dev/null 2>&1
Example:
25 02 * * * /home/shiv/tulip.sh 1>/dev/null 2>&1
See crontab man page more.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 02:50 PM
02-05-2006 02:50 PM
Re: configuring cron job
You asked about, The scritp names is say "tulip.sh" and i want execute at 2.25am every day. what should be the syntax ?
25 02 * * *
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 04:15 PM
02-05-2006 04:15 PM
Re: configuring cron job
My typical crontab looks as follows:
25 02 * * * /home/shiv/tulip.sh 1>/dev/null 2>&1
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 04:18 PM
02-05-2006 04:18 PM
Re: configuring cron job
A great introduction about "Cron"
http://www.unixgeeks.org/security/newbie/unix/cron-1.html
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 06:14 PM
02-05-2006 06:14 PM
Re: configuring cron job
- remember to put /dev/null 2 to your cript
1 mean standard input
2 mean default error
SYNTAX
25 02 * * * path/script 1>/dev/null 2>&1
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 06:21 PM
02-05-2006 06:21 PM
Re: configuring cron job
A great Wiki resource, http://en.wikipedia.org/wiki/Cron
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 07:27 PM
02-05-2006 07:27 PM
Re: configuring cron job
man cron will definetly help you better understanding the concept.
25 02 * * * /fullpath/script/ 1>/dev/null 2>&1
refer this link for more details;
http://www.adminschoice.com/docs/crontab.htm
--
Prabu.S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 09:37 PM
02-05-2006 09:37 PM
Re: configuring cron job
prior to the backup in the weekend.
And start is afterwards.
Please not the cron is run with /usr/bin/sh
shell (there can be an impact depending
which shell you use), this is the default.
############################################
# Stop / Start WebSphere for Oracle offline backups
#############################################25 17 * * 6 "/etc/cmcluster/devnew/WebSphere_Stop.sh > /tmp/WebSphere_Stop_devnew.cronlog 2>&1"
30 15 * * 2 /etc/cmcluster/devnew/WebSphere_Start.sh > /tmp/WebSphere_Start_devnew.cronlog 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 09:46 PM
02-05-2006 09:46 PM
Re: configuring cron job
Just a quick check if you are configuring cronjob on a MCSG make sure that you make the changes in the
/etc/cmcluster/PRODNAME so that it carries forward to the faliover node otherwise it will always run on the First Node you configured not on the Running Node.
HTH,
Shivam Tiwari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 08:16 AM
02-15-2006 08:16 AM
Re: configuring cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 08:26 AM
02-15-2006 08:26 AM
Re: configuring cron job
To execute a script every *hour* of every *monthday* of every *month* on every *weekday* do:
0 * * * * /pathname/scriptname
The script will run at 0-minutes after the hour.
NOW, go read the 'crontab' manpages, please! :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 09:16 AM
02-15-2006 09:16 AM
Re: configuring cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 09:22 AM
02-15-2006 09:22 AM
Re: configuring cron job
When I wrote, "NOW, go read the 'crontab' manpages, please!", I meant my comment to be helpful.
The manpages are a reference not a tutorial, that's true.
However, the more you struggle to read them, the easier it becomes. Keep trying :-))
No points for this please.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 04:09 PM
02-15-2006 04:09 PM
Re: configuring cron job
if you see my above reply, the last line help me a lot when assigning the time/frequency when my script has to run, i.e.
#******************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|-------------------------
#******************************************************
#******************************************************
# END OF TABLE day0->Sunday day6->Saturday
#******************************************************
This is very helpful. (maybe if you copy paste these line in notepad, it would be more readable and will make more sense to you) I have it in all my crontabs. It helps a lot and i use it everytime i want to verify that i have written everything well!
Also, referring to comments by above guru, most of one's queries is found in man pages. Though not easily "readable", these are very technical and informative. Every sysadmin loves it!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2006 10:33 PM
02-15-2006 10:33 PM
Re: configuring cron job
My advice would be do like me and write a Header for all your cronfiles with the summarized syntax e.g:
# /sm/cron/cronfile.root
# crontab file for the super-user.
#
# ==========================================================================
# F O R M A T
# ==========================================================================
# Minute Hour Month_Day Month Weekday Command
# (0-59) (0-23) (1-31) (1-12) (0-6)*0=sun run-string
# * = in any crontab field represents all legal values.
# Therefore, to schedule the ps(1) cmd to execute at 5:10pm on every
# friday and monday during june, july, august, you would make an entry
# in your crontab fithe that looks like this :
# 10 17 * 6,7,8 1,5 ps>>psfile 2>&1
# The 2>&1 redirects any error msg to the file psfile.
# ==========================================================================
# archive annuelle de l export le 3 dimanche de janvier chaque annee
#00 04 * 1 0 /sm/bin/archive_annuelle >>/sm/log/archive_ann.er 2>&1
...
You may notice I also put the file in a place where all cronfiles should be (my standards...) with the name of the user of this cronfile. So I rarely (almost never) use crontab -e and can then alway compare the curent and the file for modifications and if there are any ask why (especially roots) I am not informed... some modifications are done by software installation (...)
Dont forget to explicitely redirect ouputs (std and error) otherwise cron will keep on sending you mails about them...
If you do read a .profile to set env variable or do a su -
if [[ $- = *i* ]]; then #tty interactive test (VBE - 030306)
# set term if it's not set
...
fi
otherwise cron will in the messages it will send complain its "not a typewriter"...
Now you should be able to write down a crontab script that is easily readable and exempt of most common errors...
All the best
Victor