[systemd-devel] how to run a script which takes about 30 seconds before shutdown
zerons
sironhide0null at gmail.com
Fri Nov 11 14:31:00 UTC 2016
On 11/11/2016 08:44 PM, Lennart Poettering wrote:
> On Wed, 09.11.16 21:11, zerons (sironhide0null at gmail.com) wrote:
>
>> Hi everyone.
>>
>> Everyday, I need to do something like `git pull` after system
>> bootup and `git push` before shutdown. I am using Ubuntu 16.04.
>> I have tried to put some script into /etc/rc0.d/, /etc/rc6.d/,
>> each time the script runs, the network has been stopped, so I
>> turn to systemd.
>>
>>
>> === Here is a test .service file.
>> [Unit]
>> Description=test systemd
>> Conflicts=reboot.target
>> After=network-online.target
>> Wants=network-online.target
>
> If you only care about shutdown, then After=network.target shouls
> suffice, as long as your network management service properly orders
> itself against that. See systemd.special(7) for details on this.
>
> Note that systemd only provides a number of hooks we document
> semantics for, but it's up to downstream packages to actually honour
> these correctly.
>
> Lennart
>
Thanks, I have tried this. When this script runs, `ifconfig`-> `ping`
-> `ifconfig`, when `ping` runs, the network is unreachable, packet 87%
loss(only the first one received), then the net interface has no
"inet addr". I couldn't figure this out:(
More information about the systemd-devel
mailing list