Cron / crontab
System crontab
The system’s crontab is, unlike on many other Unix flavors, not located in /etc/crontab, but in /var/cron/tabs/root. In other words, the system’s crontab is seen on OpenBSD as a user’s crontab. Specifically: as the crontab of the user root.
- If you’d like to view the crontab of root, run as user root:
crontab -l - If you’d like to edit the crontab of root, for intance to change the time the /etc/daily, /etc/weekly and /etc/monthly scripts are run, do as user root:
crontab -eEdit the then presented file to your own liking. When you’re done save and quit vi. The new crontab will automaticly be activated.
- If you’d like to remove the crontab of root, run as user root:
crontab -rBut you probably never want to do this!
If you’d like cron to backup your root filesystem (/) each day, do the following:
- Edit the system’s crontab:
crontab -e - Insert the following line near the other variables:
ROOTBACKUP=1 - Edit
/etc/fstabto have a line like this:
/dev/wd1a /altroot ffs xx 0 0
You must only change “/dev/wd1a” to reflect the filesystem where the backup should be copied to. Make sure it has enough room to hold the complete/filesystem.
Permissions
The crontab files of users are located in /var/cron/tabs. Whether normal users are allowed to use crontab is determined by two files:
/var/cron/cron.allow:
If this file exists, users listed here (one username per line) are allowed to use cron. All other users are disallowed to use cron./var/cron/cron.deny:
If this file exists but the/var/cron/cron.allownot, users listed here (one username per line) are disallowed to use cron. All other users are allowed to use cron.
If both files do not exist, only root can use crontab. If they exist, but are not readable by crontab, users will be disallowed to use crontab.
Normal users
Normal users can use crontab in the same way as root does. They can also create a file in the correct crontab format and load it by running:
crontab <filename>
Actually, the systems crontab can be loaded in the very same way, but generally the crontab -e method is preferred.