crontab PATH and USER

后端 未结 5 1772
野性不改
野性不改 2020-11-27 15:29

I am new to scheduling tasks with cron and crontab. I am trying to schedule execution of a task as if I had logged on, opened a terminal, and executed it myself.

Ho

5条回答
  •  离开以前
    2020-11-27 15:42

    crontab is not a bash script, you can't use environment variables that are normally available in a shell.

    Try moving all that code into a shebang'ed script file (one starting with the line "#!/bin/bash") and run that script in the crontab.

    I'm not sure, but i think PATH (and maybe EMAIL if you set it) may be the only one you can access inside the crontab file .

    EDIT: Check the crontab 5 man page, there quite a few environment variables aviable, all set by the cron daemon.

提交回复
热议问题