Crontab Cheat Sheet
Published on 23 Jun 2019
The Linux crontab
is a time-based job scheduler that allows users to schedule commands to run periodically at fixed intervals. It is a built-in utility in Unix-like operating systems, including Linux. That enables users to automate repetitive tasks without manual intervention.
How it works
# minute (0-59),
# | hour (0-23),
# | | day of the month (1-31),
# | | | month of the year (1-12),
# | | | | day of the week (0-6 with 0=Sunday).
# | | | | | commands
3 2 * * 0,6 /some/command/to/run
3 2 * * 1-5 /another/command/to/run
Cron Logs
/var/cron/log # (cron history information)
/var/cron/olog # (moves log file to /var/cron/olog if log file exceeds system ulimit)
# The file looks something like this:
! *** cron started *** pid = 260 Tue Jun 4 00:30:56 2002
> CMD: [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1
> root 429 c Tue Jun 4 02:01:00 2002
< root 429 c Tue Jun 4 02:01:00 2002 rc=1
> CMD: /usr/sbin/logadm
> root 440 c Tue Jun 4 03:10:00 2002
< root 440 c Tue Jun 4 03:10:00 2002
> CMD: [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
> root 452 c Tue Jun 4 03:30:00 2002
< root 452 c Tue Jun 4 03:30:00 2002
# It provides the following:
a) the CMD is the command that was run
b) next entry is the time the job started
c) next is the time the job finished
d) rc is the return code from the job
all tags
IDE architecture" cli crontab crypto csv database docker editor error exceptions fastapi ffmpeg filename git go history http iteration javascript linux logging me mysql numpy orm pdo pentaho php postgres python random rename rsync rust selenium server solana sql sqlite ssh typescript user w3m wordpress