1

I have added the following line in contab

 1 * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py

my sample.py file

  text_file = open("sample.log", "a")
  text_file.write("Hi...")
  text_file.write("\n")
  text_file.close()

If I run the python program in terminal it's working fine and also append the text in sample.log file. But there is no response if add the program in crontab.

Thanks

1

2 Answers 2

6

You need a correction :

* * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py

to run it every minute.

Your cron statement : 1 * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py

would run it only at first minute of every hour eg 09:01, 10:01...etc. Hence, you will have to wait 1 hour to see the result.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your response. yes. I am running the command for every minute.
github.com/homer6/frequent-cron if you want to run more frequently than once a minute...
@sasi Why was the other answer voted as correct answer ? Was that the actual problem you were facing instead of this ?
you should use */1 * * * * to run every minute, 1 * * * * runs first minute of every hour..
0

change python instead of /usr/bin/python, Change your code as follows.

1 * * * * python /home/prkumar/Desktop/python/sample.py >> /home/prkumar/Desktop/python/output.log

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.