Are there any good crontab syntax checkers, or entry tools? [closed]

Posted on

Problem :

Recently a user on one of our systems (linux Ubuntu, but any *nix would be the same) had a crontab file missing a terminating newline.

It is common for *nix configuration files to require that terminating newline, cron being no different. However, no warning is provided when adding a file with no newline, and the command is never executed.

So, two fixes identify themselves.

  1. Run a cron process to check for
    these files.
  2. Provide a friendlier front end to cron.

The second is what this question is about. Either something to check the syntax before entering the file, or to front the whole entry process, which is a bit arcane anyway.

For this particular machine a command-line tool would be needed, since it is located at a data centre, and an X environment is not installed.

Solution :

I like the cron interface in webmin.

I’ve always found that the syntax coloring in vim was enough to do this for me. I haven’t run into the newline problem simply because I’ve trained myself to be automatic with it, like driving is, so you get those experiences where you drive while thinking about something absorbing and you get out of the car and wonder to yourself “How did I get here? I don’t remember the trip at all!” — “Damn, where did all these newlines come from?”

There is now CronSandbox.

This is a ‘sandbox’, somewhere safe to explore crontab commands. Enter the timing values, CronSandbox validates the syntax and delivers the future dates and times the job would execute.

I changed my default editor to emacs, which asks if you want to end the buffer with a newline on exit 🙂

setenv EDITOR <editor>

in your .bashrc (or appropriate) should handle that solution 🙂

To answer part two of your question, you can also just drop scripts in the cron.<period> directories in /etc

Leave a Reply

Your email address will not be published. Required fields are marked *