When crontab contains > 10 * * * * yuri env DISPLAY=:0.0 /usr/local/bin/bash /path/to/some/script this script is run by cron(8) with HOME=/var/log Once the field "who" in crontab is set to some user, cron(8) should also set the "HOME" environment variable properly. HOME=/var/log looks wrong in any case. (Not sure if "root" also suffers from this problem.) FreeBSD nohost 12.0-STABLE FreeBSD 12.0-STABLE r347548 GENERIC amd64
Can't reproduce on 12.0-STABLE r349024 GENERIC amd64.
On 12.0-STABLE r347548 GENERIC amd64 Add this line to /etc/crontab: > * * * * * yuri /home/yuri/cron-env-test.sh /home/yuri/cron-env-test.sh contains: > #!/bin/sh > echo "`date`: "$HOME >> /tmp/cron-env-test.txt It printed into /tmp/cron-env-test.txt: > Fri Jun 21 02:18:00 PDT 2019: /var/log
This bug refers to /etc/crontab. crontab(5) says "HOME [is] set from the /etc/passwd line of the crontab's owner", true for user crontabs but apparently not for /etc/crontab. This looks like a documentation problem. crontab(5) doesn't really describe /etc/crontab, cron(8) notwithstanding.
(In reply to Yuri Victorovich from comment #2) The line I added in /etc/crontab is: * * * * * WHR /home/WHR/cron-env-test.sh cron-env-test.sh file is exactly same. The result is: [WHR@x ~]$ cat /tmp/cron-env-test Fri Jun 21 20:41:00 CST 2019: /usr/home/WHR Fri Jun 21 20:42:00 CST 2019: /usr/home/WHR Fri Jun 21 20:43:00 CST 2019: /usr/home/WHR Fri Jun 21 20:44:00 CST 2019: /usr/home/WHR Fri Jun 21 20:45:00 CST 2019: /usr/home/WHR Fri Jun 21 20:46:00 CST 2019: /usr/home/WHR [WHR@x ~]$ uname -a FreeBSD x 12.0-STABLE FreeBSD 12.0-STABLE r349024 GENERIC amd64