Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.


Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.


Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.


Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells

Croncal – the Cron Calendar

Submitted by on August 9, 2017 – 10:52 am

The croncal is a clever Perl script that reads entries in your crontab and outputs a schedule, showing the time when cron jobs will run.

This can be useful when planning for server downtime, for example. You may want to know what cron jobs will fail to run and how many times. To download the script:

mkdir -p ${d}
wget -O ${d}/${f} --no-check-certificate "${f}"
chown root:root ${d}/${f} 2>/dev/null
chmod 755 ${d}/${f} 2>/dev/null
ln -s ${d}/${f} /usr/bin/croncal 2>/dev/null

To use croncal you need to specify three parameters: start time, end time, and the crontab file. The time must be entered in the following format: YYYY-mm-dd HH:MM The following example will list all /var/spool/cron/root cron jobs that will run on the server in the next hour:
s=$(date -d 'now' +'%Y-%m-%d %H:%M')
e=$(date -d 'now +1 hour' +'%Y-%m-%d %H:%M')
croncal -s "${s}" -e "${e}" -f /var/spool/cron/root

Sample output:
2017-08-09 11:00|/opt/diskminder/ >/dev/null 2>&1
2017-08-09 11:05|salt-run -t 60 manage.down 2>/dev/null | sed -e "s/[\[', ]//g" > /tmp/salt-minion-down
2017-08-09 11:20|/var/adm/bin/ >/dev/null 2>&1

Here’s another example: I am using Salt to count all cron jobs in /var/spool/cron on all servers that run during the week:
s=$(date -d 'last Monday' +'%Y-%m-%d 00:00')
e=$(date -d 'next Monday' +'%Y-%m-%d 00:00')
salt --output=txt "*" "for i in `ls /var/spool/cron` ; do croncal -s \"${s}\" -e \"${e}\" -f /var/spool/cron/${i} 2>/dev/null; done" 2>/dev/null | wc -l

Sample output:

So the next time your boss says you need to automate more, tell him how many things are happening automatically already :)

Print Friendly, PDF & Email

Leave a Reply