I recently wanted to schedule automatic tasks on OpenBSD system. A big surprise for me was that, unlike Linux distributions, there was no default /etc/crontab file.
It's not that hard to implement, but there are some aspects to take into account in order to create it, which we will see here.
Before going further, there are some things to know about setting up the /etc/crontab file.
root@host:~# touch /etc/crontab
root@host:~# chown root:wheel /etc/crontab
root@host:~# chmod 0600 /etc/crontab
Here's an example where we want to download the br.zone file (containing all IP addresses from Brazil) on the 12th day of every month at 5:00am.
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 5 12 * * root wget --no-check-certificate https://www.ipdeny.com/ipblocks/data/countries/br.zone -O /etc/tables/br.zone
root@host:~# tail -f /var/cron/log
Apr 12 00:05:01 BSDhost cron[3577]: (root) CMD (wget --no-check-certificate https://www.ipdeny.com/ipblocks/data/countries/br.zone -O /etc/tables/br.zone)
Contact :