I found that setting my crontab PATH=/home/toothrot/bin worked, but $HOME/bin did not. And I checked that $HOME is set as expected. Does cron not expand environment variables? I tried using it by calling a script in the path.

* * * * *   fetchmail

This script writes a log file when PATH is set to the full explicit path, but not when using $HOME, presumably because in the latter case it is not run.

  • 1
    How did you use it?
    – Jeff Schaller
    Commented Sep 4, 2019 at 12:23
  • @JeffSchaller, see edit.
    – Toothrot
    Commented Sep 4, 2019 at 12:26
  • What's output of tr '\0' '\n' < /proc/cron-pid/environ | grep HOME? Commented Sep 4, 2019 at 12:28
  • @ArkadiuszDrabczyk, zsh: no such file or directory: /proc/cron-pid/environ
    – Toothrot
    Commented Sep 4, 2019 at 12:30
  • You didn't get it, you need to replace cron-pid with the correct PID you can find using ps aux | grep '[c]ron' Commented Sep 4, 2019 at 12:31

1 Answer 1


You didn't specify what cron implementation you are using, however at least in Debian based systems (where it is derived from Vixie cron IIRC) it does not. From man 5 crontab:

       An  active line in a crontab will be either an environment setting or a
       cron command.  The crontab file is parsed from top to  bottom,  so  any
       environment  settings  will affect only the cron commands below them in
       the file.  An environment setting is of the form,

           name = value

       where the spaces around the equal-sign (=) are optional, and any subse‐
       quent non-leading spaces in value will be part of the value assigned to
       name.  The value string may be placed in quotes (single or double,  but
       matching)  to  preserve  leading or trailing blanks. To define an empty
       variable, quotes must be used. The value string is not parsed for envi‐
       ronmental substitutions or replacement of variables, thus lines like

           PATH = $HOME/bin:$PATH

       will not work as you might expect. And neither will this work

           C=$A $B

       There will not be any subsitution for the defined variables in the last

       An alternative for setting up the commands path is using the fact  that
       many shells will treat the tilde(~) as substitution of $HOME, so if you
       use bash for your tasks you can use this:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .