cron job commands
crontab -l
#to check cron jobs on your debian
crontab -r
#to remove
crontab -e
#to edit
simple example in virtualenv
enter full path to the file where you want to store your logs. e.g
* * * * * echo ‘Run this command every minute’ >> /home/aameer/Documents/projects/project_name/logs/file.log 2>&1
Python version to be used has also to be mentioned, we can check it by runnig following file(say crontest.py) with a cron job
1
2
3
4
5
import sys
print ("-")
print ("Python Version used")
print (sys.version)
print ("Minute over")
* * * * * python /home/aameer/Documents/projects/project_name/crontest.py >> /home/aameer/Documents/projects/project_name/logs/file.log 2>&1
#Moreover to start or stop a cron job
sudo service cron start
sudo service cron stop
#to use different python version we provide path ~/.virtualenvs/project_name/bin/python3.4 /home/aameer/Documents/projects/project_name/crontest.py » /home/aameer/Documents/projects/project_name/logs/file.log 2>&1