0

I have a Python script which outputs to standard out, and the scripts resides in /usr/local/bin so I run the following command to redirect the output: ./myscript >> /home/user/output.csv.

However I need to run the script as a Cron job every minute (whether I am logged in or not) and I am unsure of the Cron syntax to redirect to "output.csv" which is in my home directory.

This is what I've come up with but I am fairly sure that redirecting from Cron won't be that simple:

 0 0/1 * 1/1 * ? *  /usr/local/bin/myscript >> /home/user/output.csv

How do I do it correctly?

jww
  • 97,681
  • 90
  • 411
  • 885
user9993
  • 5,833
  • 11
  • 56
  • 117
  • Have you tried this already? Have you tried putting your `./myscript >> /home/user/output.csv` in another file, say `job.sh`, and run that with a cronjob? – Felk Nov 24 '15 at 23:11
  • What you have there is far from every minute. Every minute is the simplest thing in cron: `* * * * *`. And redirecting from cron *is* that simple. (I'm talking about vixie cron syntax, by the way.) – 4ae1e1 Nov 24 '15 at 23:12
  • Possible duplicate of [Redirecting the output of a cron job](http://stackoverflow.com/questions/14982980/redirecting-the-output-of-a-cron-job) – Dan Cornilescu Nov 25 '15 at 02:13

1 Answers1

0

Yes, it is this easy. But also note the comment from 4ae1e1 on the cron syntax. For a job that runs every minute it has to be

* * * * * /usr/local/bin/myscript >> /home/user/output.csv

karoshi
  • 221
  • 3
  • 6