"-":4: bad minute when installing crontab from a file
- May 6th, 2014
I recently had to migrate a rather messy crontab from one server to another and to try and simplify things I wanted to split the crontab into managable chunks.
Unfortunately the crontab does not have any import / include functionality and I didn't want to use different user accounts to have different crontabs (this would likely cause permission issues, a management headache, and I would be replacing one messy solution with another) so after a quick Google I found that the solution was to create the separate files and concatentate them into the crontab. i.e.
cat site1.cron site2.cron | crontab
However, when I tried this I got presented with:-
[[email protected] crontab]$ cat site1.cron site2.cron | crontab "-":4: bad minute errors in crontab file, can't install.
As I was updating the site1.cron and site2.cron files using Windows I was running into issues with differences in line ending between Windows and Linux, so to resolve this simply run it through dos2unix first i.e.
cat site1.cron site2.cron | dos2unix | crontab
Now the crontab installs perfectly and no more bad minute error message.