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

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
List your cron file:
# crontab -l
Backup all your cron jobs:
# crontab -l > ~/backup.cron.jobs
Remove ALL cron job:
# crontab -r

Task: Crontab file format

Cron file format is as follows:

0-59   0-23      1-31      1-12         0-6     /root/scripts/backup2tape.sh

Easy to remember crontab file format:

* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- 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:
# crontab -e
Append following

0   23  * *  * /root/script/backup

Run foo job very weekday (MON-Fri) at 6am, enter:

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

For more information refer to cron and crontab man pages.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 8 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
8 comments… add one
  • David Jan 15, 2008 @ 0:21

    You might note that all files normally found in /etc/init.d, /etc/rc*.d, and others are all in /sbin in HP-UX 10.20 and up.

    Note too that your formatting is off in the description of the /etc/rc.config.d/cron file. Also, if you run /usr/bin/cron instead of /sbin/init.d/cron start, the /etc/rc.config.d/cron file is not used.

  • rag Jan 16, 2008 @ 7:50

    it is very usefull

  • satya Jul 14, 2008 @ 18:48

    Cron: Your job did not contain a valid audit ID.

  • SAGAR Mar 21, 2011 @ 5:09

    How can i schedule to run the job for a certain time in a day,say for 1am to 2am.Is it possible using crontab.

  • Ramesh May 5, 2011 @ 11:50

    hi all,

    can anybody help me how to give permission to user to enable /disable cron daemon in redhat linux.

  • Vicky Oct 18, 2011 @ 11:03

    how do i tell cron to stop a running script?

  • Jorgito Oct 23, 2012 @ 16:29

    Is there any way to look at the logs from the cron?
    I’m able to schedule the jobs,
    and I have one of them not running properly, (if i run it manually i can get the updated result, but i scheduled the task as to not need to run it manually)
    I know one must define the enviroment variables on the script , but i did defined them.
    so basically I’m missing something and will be nice to check logs as to find out what is it instead of blindly make changes.

  • Harunur Rashid Apr 25, 2013 @ 4:17

    very useful command for HP-Unix cron job.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum