0

I want to run a python file with bash script for a certain time of the day. I script.sh like this (ofcourse execute it with chmod +x before)

    #!/bin/bash
    python /home/user/file.py

and with crontab -e I wrote

    * 01 * * * /home/user/script.sh

How can I make it run on 1 o'clock?

Edit: I have to run python file from a script because I will add some other things later.

7
  • You can just call the python command directly from cron. So do * 01 * * * python /home/user/file.py Commented Jun 14, 2016 at 9:26
  • 3
    whats the problem with your implementation? does it fail to execute? Commented Jun 14, 2016 at 9:27
  • Thank you @NoelEvans but I will add script some other things. I need to run it from the script. Isn't there a way to do it? Commented Jun 14, 2016 at 9:30
  • 2
    What is is the problem with how your currently have it ? Commented Jun 14, 2016 at 9:32
  • 1
    Make sure you use the full path to python. cron does not set PATH. Commented Jun 14, 2016 at 10:11

1 Answer 1

1

Put a shebang/directive in the python script you're trying to run.

Similar to the shell script you gave, this should be the first line in your python script:

#!/usr/bin/python

...or for python version 3:

#!/usr/bin/python3
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.