When I add that path to PATH in /etc/environment, the user can call the script without providing the full path but the daemon can not; it just says "not found".
According to this source, which is IBM AIX documentation (I could not find anything else) but is presumably true in general:1
The first file that the operating system uses at login time is the
/etc/environment file. The /etc/environment file contains variables
specifying the basic environment for all processes.
Note that it is not sourced in any system wide .profile
, so this is hard-coded somewhere. However, if it applies "at login time", it will not apply to a daemon, which is started by init and never logs in (although "for all processes" contradicts this, perhaps that was just a poor choice of words).
According to this superuser Q&A, /etc/environment
is part of PAM, which supports the "at login" premise and again means it will not be used by init spawned daemons. There are a lot of other references for this too, but not, it seems, actual PAM documentation.
should I rather always use full path names?
This is the most common and generally recommended process -- it is possible for daemons to start with no $PATH at all. So you could set this yourself in a start-up script, or, as you say, use full path names as appropriate.
1. "/etc/environment" does not appear at all in what would seem to be the relevant POSIX specs [1] [2].