Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting cron job 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
As a user to Solaris 7 how do I get a crontab job?

I have the script written and now need it ran once a day.

Are they always stored in /var/spool/cron/crontab or can I run it from my home directory ???

Where do I start and what are my steps to get one started.
 
In order to set up a cron job, you need to do the following:
1. set the environmental variable EDITOR to your editor of choice (i.e. EDITOR="/usr/bin/vi" ; export EDITOR)
2. if you want this cron job to run as root, then while logged in as root, execute: crontab -e
3. if you want this cron job to run as another user, recommended, while logged in as that user, execute: crontab -e
4. make the necessary entries to the file, for example:

00 6 * * 1-5 [ -x /usr/local/scripts/avail_media ] && /usr/local/scripts/avail_media 2>/dev/null

this entry will execute the script /usr/local/scripts/avail_media at 6:00am M-F

5. once you are finished w/ your entries, quit the editor program (i.e. :wq! - if using vi) **do not use <CTRL>-D
6. to see if your cron entry was successful, execute: crontab -l
7. if you see your entry listed, then you entered it properly.

Brantley Fry
Systems Administrator I
 
As analternative you may wish to work on a copy of yoru crontab, and then when finished, input that back into crontab.

ie

#crontab -l > mycron
#vi mycron
*make changes* and then save, exit

now update the current cron schedule for this user by:
#crontab mycron
#rm mycron

br,
N.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top