[CentOS] Running script before reboot or shutdown

Tue Dec 22 15:55:07 UTC 2020
centos2 at foxengines.net <centos2 at foxengines.net>


On Tue, Dec 22, 2020, at 08:12, centos2 at foxengines.net wrote:
> 
> 
> On Tue, Dec 22, 2020, at 07:56, J Martin Rushton via CentOS wrote:
> > This could be the same issue that people run into when designing cron 
> > jobs.  You may only have a limited set of directories on you $PATH 
> 
> Is this a systemd limit? On one of my systems I've got 233 directories (5445 non-colon chars) in interactive shell PATH and generally things work fine.

I misunderstood your meaning about the PATH but I understand now. you're referring to the default path defined in the shell.
The Bash man page says, "The default path is system-dependent, and is set by the administrator who installs bash.", (so the CentOS packager?), and then continues on with "A common value is ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''." That covers putting the script in /usr/local/bin, but then, that might not be what's on your system. On the CentOS 7.9 system I am working with, the default is:

   /usr/bin:/bin

As reported by a very simple cron job that writes PATH to a file in tmp.
For cron jobs I usually use the full path to the script in the crontab then set and export the PATH in the script itself.