Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I prefer to stick scheduled tasks in /etc/crontab so I can see at a glance what's scheduled to run, regardless of which user the task runs as.

The only gotcha is that the format isn't validated on save, unlike crontab -e -- so a stray character can quietly break the entire cron.

Is there a way to validate the /etc/crontab format before/after save?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

This has already been answered over on Stack Overflow.

share|improve this answer
3  
It should be noted that the answer on Stack Overflow was specifically solving the question with PHP, which may or may not be useful for some people. –  Dave Wongillies Aug 30 '13 at 2:17
    
not the kind of answer I was looking for.. perhaps something which is not specific to php.. anything but a library.. –  Gaurav Agarwal Jan 13 at 8:41

Wicked cool shell scripts by Dave Taylor has a shell script that validates crontab files.

You can get the script at the site for the books: verifycron.
Thanks to seth for the hint.

share|improve this answer
1  
Source is on the site for the book as well: intuitive.com/wicked/showscript.cgi?053-verifycron.sh Really like that book. –  seth Jul 21 '09 at 19:58
    
@seth: Added the link to the answer, thanks. –  Ludwig Weinzierl Jul 21 '09 at 20:18

Another more recent solution is the python script chkcrontab

share|improve this answer

chkcrontab works perfectly to me! Thanks Dave. Unfortunately, this site doesn't me to vote yet.

To install it (as root user, or use with the prefix command sudo):

pip install chkcrontab

If you haven't pip installed, try before:

apt-get update
apt-get install python-pip
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.