Re: Running script before reboot or shutdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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 and other environment variables may be missing. If this is the case, ensure that you define the full path to utilies:

	MYPROG="/home/carlos/myprog"
	$MYPROG -h

rather than

	myprog -h

HTH, and BTW you can still use init scripts if it is easier.

On 22/12/2020 11:51, Carlos Lopez wrote:
Hi all,

I am trying to configure a script as a systemd service to run first when a shutdown or reboot is called. This script execute some scp commands to copy some files to other machines. My actual defined systemd’s file is:

[Unit]
Description=Remote copy some files before reboot/shutdown
Before=poweroff.target halt.target shutdown.target reboot.target
DefaultDependencies=no

[Service]
Type=simple
ExecStart=/bin/true
ExecStop=/usr/local/bin/remote_copy
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

But it doesn’t work. “remote_copy” is working when it is executed from root shell. I am using CentOS-8 fully patched release.

Any idea what am I doing wrong?

Regards,
C. L. Martinez
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos


--
J Martin Rushton MBCS
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux