So I'm trying to make some python script run every 6 hours using crontab but for some reason it doesn't work.
crontab -l
0 */6 * * * cd /home/david/InstaPy && /usr/bin/python3 quickstart.py
>> david.log
Also tried to run it every minute for checking purposes but that doesn't work either. Looked through the crontab log file and also not seeing it executing - var/log/syslog
User Crontab :
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7)
# | | | | |
# * * * * * command to be executed
1- first of all I would suggest you execute the process with :
0 */6 * * * cd /home/david/InstaPy && python3 /yourpath/quickstart.py
2-Ensure the file has execute permissions.
chmod +x /path/to/file
3-check that your password hasn't expired., since once it has, all cron jobs stop
4- try to redirect the output of your process :
0 */6 * * * cd /home/david/InstaPy && /usr/bin/python3 quickstart.py >> /whateverpath/sample.log 2>&1
5- check your environment variables :
0 */6 * * * . $HOME/.profile; /path/to/command/to/run
In this case it will pick all the environment variable defined in your `$HOME/.profile file.