简体   繁体   中英

cron python file doesn't work on centos 7

i'm trying to schedule my pythohn script into Centos 7 with cron. On my script at start i have added this:

#!/usr/local/bin/python

and this is my cron file that i have create into folder that contain python file

*/5 * * * * /usr/local/bin/python /home/Documents/SCRAPE_PYTHON/SCRAPE.py &>> /home/Desktop/log.txt

i have try to run the script into terminal by chmod +x and works fine. But whit this configuration when in terminal i set crontab .cron the job doesn't work. The log file set into cron file are not write and script not run. The script could be write some data into db and the db is always empty. Any help??? Thanks

Type crontab -e in the shell, this will open the cron editor. Here copy paste the entire command.

*/5 * * * * /usr/local/bin/python /home/Documents/SCRAPE_PYTHON/SCRAPE.py &>> /home/Desktop/log.txt

Now press Esc key then type colon :wq! and press Enter key. This will install your cron. Your cron should run every 5 minutes.

Your standard output and error will be appended to /home/Desktop/log.txt .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM