0% found this document useful (0 votes)
608 views

HP-UX UNIX: Start / Stop and Configure Cron Services

Cron is used to automate tasks on HP-UX systems. It can be enabled by setting the CRON variable to 1 in the /etc/rc.config.d/cron file. Cron jobs are configured in individual user crontab files located in /var/spool/cron/crontab. The crontab command is used to edit, list, and remove cron jobs. Cron jobs are formatted to run commands or scripts at specified days and times.

Uploaded by

rahulkedar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
608 views

HP-UX UNIX: Start / Stop and Configure Cron Services

Cron is used to automate tasks on HP-UX systems. It can be enabled by setting the CRON variable to 1 in the /etc/rc.config.d/cron file. Cron jobs are configured in individual user crontab files located in /var/spool/cron/crontab. The crontab command is used to edit, list, and remove cron jobs. Cron jobs are formatted to run commands or scripts at specified days and times.

Uploaded by

rahulkedar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

HP-UX UNIX: Start / Stop and Configure Cron Services

Q. I need to run a backup and other stuff everyday. How do I check and start cron service under HP-UX UNIX operating system? How do I write cron jobs? A. Cron service is required to run jobs and tasks such as backup. You must login as the root to run following commands. Each user that is using the cron service must have a cron configuration file in the /var/spool/cron/crontab directory. Also users are permitted if their name appeared in /var/adm/cron/cron.allow file

Task: Find out if cron is running under HP-UX


Type the following command at a shell prompt
# ps -ef | grep cron

Open /etc/rc.config.d/cron file


vi /etc/rc.config.d/cron

Set control variable to 1 to enable cron : CRON=1 Set control variable to 0 to disable : CRON=0 Close and save the file. To start or stop cron you can type the following command:
# /sbin/init.d/cron start <-- start cron # /sbin/init.d/cron stop <-- stop cron

Task: HP-UX Start cron service


If cron is not running, simply type:
# cron

Task: Edit / create cron jobs


Type the following command to submit a cron job:
# crontab -e # crontab -l

List your cron file: Backup all your cron jobs: Remove ALL cron job:
# crontab -r # crontab -l > ~/backup.cron.jobs

Task: Crontab file format


Cron file format is as follows:
MIN 0-59 * | | * | | * | | * | | HOUR 0-23 DATE 1-31 MONTH 1-12 DAY 0-6 /PATH/TO/COMMAND /root/scripts/backup2tape.sh

Easy to remember crontab file format:


* command to be executed | ----- Day of week (0 - 7) (Sunday=0 or 7)

| | | ------| | --------| ----------------------# crontab -e

Month (1 - 12) Day of month (1 - 31) Hour (0 - 23) Minute (0 - 59)

To run /root/script/backup at 23:00, every day, enter: Append following


0 0 23 6 * * * * * /root/script/backup 1-5 /root/script/backup

Run foo job very weekday (MON-Fri) at 6am, enter: For more information refer to cron and crontab man pages.

You might also like