Let's say I write cron files via script and modify them direct under
/var/spool/cron/crontabs/
. When using the command crontab -e
crontab checks the syntax when I exit the editor. Is there any way to do the same check via script?
Crontab with -e option does open your default editor with the current cron file and installs it after exiting.
First of all, save your actual cron file to be sure of not losing or breaking anything.
crontab -l > backup.cron
You can directly install a file that you have cooked:
crontab yourFile.text
Or use a pipe in a script:
#/bin/bash
Variable="your scheduled tasks"
echo $Variable | crontab
You will get the error messages in the case of bad formatting.
More info: man crontab