crontab can not be sh script

Scene example: write a timed task, performed every hour. python virtual environment management virtualenv and virtualenvwrapper

  • The following is a linux bash script main role is to run the virtual environment to execute the script
- #!bin/sh

source /home/hjj/.virtualenvs/mywork/bin/activate

python3 /mnt/e/beauty2/services/libs/schedule/crontab.py

deactivate

Before you can run this script manually, but do not always perform regular tasks. The reason is not loaded crontab operating environment, resulting in sh script can not be executed, so the Internet to find some bit of code, put crontab -e text, the environment variables.

  • The following is the code crontab -e

    SHELL = /bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    
    
    * * * * *  ./etc/profile; /bin/sh /home/hjj/cron.sh  
    
  • The results can be output in expected!

Guess you like

Origin www.cnblogs.com/jimmyhe/p/11114230.html