According to this site I set up cron to execute a script for me, first just trying to get it to work with cat before doing the actual work I need to do (actual work will need root priviliges so I did everything as root to make my life easier later):

me> sudo su
root> crontab -e

Edited the file as follows, leaving a blank line at the end:

#which cat outputs /bin/cat

# execute this every minute, if it works, change cat to my script
1 * * * * cat /home/me/source.txt 1> /home/me/destination.txt

According to this SO question, restarted the cron service to be sure it loads changes after saving the file and exiting the editor:

root> service cron restart

And then waited for a few minutes. Nothing happened. Then restarted the computer. Again, nothing. Where did I do it wrong?

  • 1
    Did you wait till the 1st minute of the hour? – Romeo Ninov Nov 20 '18 at 19:38

Your crontab is running at 1st minute of every hour. To run every minute you have to configure like this.

* * * * * cat /home/me/source.txt 1> /home/me/destination.txt
  • Thanks, didn't think that through very well. My actual task won't need to run every minute, every 15 minute is enough. Is there a shorthand for that, or do I have to copy the same command 4 times with 0 * * * *, 15 * * * *, etc.? – sisisisi Nov 20 '18 at 20:16
  • 1
    */15 * * * * cat /home/me/source.txt 1> /home/me/destination.txt. – Dinesh Mandepudi Nov 20 '18 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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