Run crontab non-interactively from script

croncrontabremote

I would like to schedule some tasks on remote servers by script but am having an issue with crontab expecting to be run interactively the first time. As far as I understand crontab needs to be initialized by first running crontab -e. Which causes it to prompt which editor to use and launch that editor.

I need initialize crontab and schedule a task on too many servers to log into each individually. Is there a way I can avoid the interactive part or script it?

The servers and my client are running Ubuntu 13.04.

Best Answer

From StackOverflow: Linux - How do I create a crontab thru a script

Cron jobs usually are stored in a per-user file under /var/spool/cron

The simplest thing for you to do is probably just create a text file with the job configured, then copy it to the cron spool folder and make sure it has the right permissions.

Related Question