21

It might be very simple question, but how could I run a python script on my fedora dist every 2 days?

Thanks

Antonis

Antonis
  • 1,061
  • 3
  • 18
  • 36
  • 8
    What part of cron confuses you? Creating the schedule? Or running a Python script? What part of the cron man pages have you read? What have you tried? What errors are you getting? Can you be more specific on what help you need? – S.Lott Dec 16 '10 at 11:28
  • 3
    S.Lott, I think he wanted a quick solution. Not sure, if these kind of questions should be encouraged. – Senthil Kumaran Dec 16 '10 at 11:32
  • Thank you anyway. I just needed a quick solution. I know should read the man pages and try different things. You are right – Antonis Dec 16 '10 at 11:38
  • 1
    possible duplicate of [Creating a Cron Job - Linux / Python](http://stackoverflow.com/questions/2339725/creating-a-cron-job-linux-python) – S.Lott Dec 16 '10 at 12:09
  • @S.Lott to his problem, - 'How to do this task' kind? – Senthil Kumaran Dec 16 '10 at 12:18
  • Thanks again both of you (the Cron schedule syntax)! – Antonis Dec 16 '10 at 14:04
  • @Antonis: If you wanted the cron schedule syntax, please **update** your question so that others can benefit from your question. – S.Lott Dec 16 '10 at 17:03

1 Answers1

66

It is a question on cron. First is add a SHEBANG line on top of your python script.

#!/usr/bin/env python

Make your script executable with chmod +x

And do a crontab -e and add 0 0 */2 * * /path/to/your/pythonscript.py

Senthil Kumaran
  • 54,681
  • 14
  • 94
  • 131
  • 9
    +w is writable, you probably meant +x. And pretty sure you should set a minute and hour. 0 0 for example. – plundra Dec 16 '10 at 11:32
  • 1
    Thanks for correcting those plundra. +w was typo and while most often I myself make the mistake of cron editing only to realize it soon and change it quickly. – Senthil Kumaran Dec 16 '10 at 11:35