Out of nothing I noticed I could not run some commands anymore, like ‘runuser’ and ‘rfkill’.
When I looked in /etc/profile I saw these lines:
if [ “id -u” -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
It seems like the second option is missing /usr/sbin and ‘runuser’ is located there.
When I added /usr/sbin there, everything started working again.
So now I have two questions:
How is it possible that this happened so suddenly? I cannot remember making any changes to my system except for updating to the latest release.
Why is /usr/sbin not included in /etc/profile?
I even had to include the new path to my cron jobs, because they dont use /etc/profile. So I think the problem is at a deeper level than just /etc/profile.
When you login as non-root user, it is normal that sbin locations (s for super user) are missing in the path, or do you mean it’s missing for the root user?
Cron jobs do not read /etc/profile (only for login sessions). ~/.bashrc is generally read with all bash shells, including scripts and cron jobs and can change the path, but by default it contains an exit path for noninteractive sessions.
So when you create a cron job with calls root-only commands like the ones you miss, either create is for the root user or use sudo within the script.
Does it work for you on a regular root login shell/session? Actually I wonder whether it is expected on user crontabs. AFAIK all the ones I use are no sbin commands.
Okay, it’s the same here on various systems, so this seems to be normal. I’ve never recognised it since I never used sbin commands in user cron tabs. So you need to define PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin (or whatever you need) in the individual crontab, or use full command paths.
/etc/crontab is affecting only the cron jobs in /etc/cron.*/.
Okay! I also tried it on three Ubuntu machines, and there I got the full path in root cron. But maybe this is different between pure Debian and Ubuntu?
The weird thing is I had a backup script running in root cron for weeks. And these backups always worked. Suddenly I get email notifications from the cron daemon about this problem. So for one reason or another, in the past I had the full path. Otherwise the backup script could have never worked like it did before.
So that will always be mystery, but let’s close this issue then. Thanks for the excellent support in any case!