How to setup cron
Cron is a clock daemon which allows you to start a job at specified date (and/or time) or every specified time period.
Firstly you need to install a package, do it as root:
installing of the package
root@dilos:~# apt-get update && apt-get install cron
After it the package should be installed in your system, let check it:
checking of the package
root@dilos:~# dpkg -l cron
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================-===================-===================-===============================================================
ii cron 3.0pl1-128-5 solaris-i386 process scheduling daemon
The output means that the package has been installed.
To know what our daemon does (run the jobs) we need to add one line into the syslog configuration.
Open /etc/syslog.conf in your favorite text editor and add the line (as root):
a line to log from the cron daemon
cron.info /var/adm/messagesYou can write it into a separated file, for example, cron.log.
After you changed syslog.conf you need to reconfigure syslog daemon (as root):
reconfiguring of the syslog daemon
root@dilos:~# svcadm refresh system-logRefresh method sends a HUP signal to the syslogd and the daemon will reread its configuration file.
Now we need to enable the service (as root):
enabling of the cron service
root@dilos:~# svcadm enable cron
Let check the status of the service:
checking status of the service
root@dilos:~# svcs cron
STATE STIME FMRI
online 10:09:20 svc:/system/cron:defaultThe state must be online, this means that the service works now.
From time to time you need to debug some jobs that cron runs, to increase a log level of the cron daemon you need to change service info (by default log level is 1).
To change this value run (as root):
changing os the log level
root@dilos:~# svccfg -s cron setprop application/log_level = astring: 15To be sure the value changed you can test it:
examining value of the log_level
root@dilos:~# svcprop -p application/log_level cron
15Don't forget to refresh the service after changes (as root):
refreshing the service
root@dilos:~# svccfg -s svc:/system/cron:default refresh
root@dilos:~# svcadm refresh cronAnd now you can restart the daemon (as root):
restarting the service
root@dilos:~# svcadm disable cron
root@dilos:~# svcadm enable cronAlways check the result of this operation, otherwise your service may be unavailable.
checking of the result
root@dilos:~# svcs -xv
root@dilos:~# ps -ef|grep cron
root 4574 1 0 19:37:39 ? 0:00 /usr/sbin/cron -L 15
root 4577 4556 0 19:37:47 pts/1 0:00 grep cronWell, done...
log level codes
1 job start
2 job end
4 job failed
8 job pid
You can combine this codes by OR (or +), in our example we set all of them (1 + 2 + 4 + 8 = 15)