Proper way to run a script using cron?

后端 未结 4 1517
后悔当初
后悔当初 2020-12-19 20:27

When running a script with cron, any executable called inside must have the full path. I discovered this trying to run wondershaper, when many errors showed when it tried to

4条回答
  •  梦毁少年i
    2020-12-19 20:52

    Declaring variables inside your cron job is more explicit and easier to maintain : all you have to modify is contained in your cron job, and you don't need to transfer multiple files should you move it to another system.

    PATH=/usr/bin:/your/fancy/dir
    MYAPPROOT=/var/lib/myapp
    
    */2 * * * * myappinpath
    */3 * * * * $MYAPPROOT/mylocalapp
    

提交回复
热议问题