cron - Crontab CD to Directory -


all of cronjob scripts run specific directory. can add cd /folder/path @ top of crontab file , expect scripts run directory?

currently crontab functions (ignore lack of specific run frequencies)

* * * * * cd /folder/path && python3 file.py * * * * * cd /folder/path && python3 file2.py * * * * * cd /folder/path && python3 file3.py 

i rather like

cd /folder/path * * * * * python3 file.py * * * * * python3 file2.py * * * * * python3 file3.py 

since crontab file not running when task being triggered not work since cron tasks run cron daemon. solution beautify commands bit add path actual scripts path env variable on crontab file

path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/path/to/scripts 

and this:

* * * * * /folder/path/file.py * * * * * /folder/path/file2.py * * * * * /folder/path/file3.py 

note name.py files should have interpreter defined @ top of file work.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -