Make HTTP call on system shutdown using systemd [CentOS 7]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I need to make a service/script that make a HTTP/POST call on system shutdown to informs a distant server that the system is going to stop.
I've tried to watch the runlevel but it looks like it is not working anymore on CentOS 7 as the runlevel is set to 3 all the time.
I've tried to make a service based on this post, I ended up with the following file :
my_service.service
[Unit]
Description=Service to execute on shutdown
After=network.target network-online.target
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/etc/path_to_my_script
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I've put the follwing line at the beggining of my script:touch /etc/test_shutdown
but the file is never created.
Do you have any idea about how to make this works ?
Thanks for your answers.
centos systemd services shutdown
add a comment |Â
up vote
0
down vote
favorite
I need to make a service/script that make a HTTP/POST call on system shutdown to informs a distant server that the system is going to stop.
I've tried to watch the runlevel but it looks like it is not working anymore on CentOS 7 as the runlevel is set to 3 all the time.
I've tried to make a service based on this post, I ended up with the following file :
my_service.service
[Unit]
Description=Service to execute on shutdown
After=network.target network-online.target
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/etc/path_to_my_script
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I've put the follwing line at the beggining of my script:touch /etc/test_shutdown
but the file is never created.
Do you have any idea about how to make this works ?
Thanks for your answers.
centos systemd services shutdown
for a local filesystem test (or to otherwise ensure that the script can actually be loaded and run from the filesystem) you probably want to copy the freedesktop.org/software/systemd/man/systemd.mount.html dependencies so the appropriate filesystems are there
â thrig
May 29 at 17:16
IâÂÂm not sure if it will work, but try changing theWantedBy=
toshutdown.target
.
â Lucas Werkmeister
Jun 1 at 12:39
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to make a service/script that make a HTTP/POST call on system shutdown to informs a distant server that the system is going to stop.
I've tried to watch the runlevel but it looks like it is not working anymore on CentOS 7 as the runlevel is set to 3 all the time.
I've tried to make a service based on this post, I ended up with the following file :
my_service.service
[Unit]
Description=Service to execute on shutdown
After=network.target network-online.target
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/etc/path_to_my_script
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I've put the follwing line at the beggining of my script:touch /etc/test_shutdown
but the file is never created.
Do you have any idea about how to make this works ?
Thanks for your answers.
centos systemd services shutdown
I need to make a service/script that make a HTTP/POST call on system shutdown to informs a distant server that the system is going to stop.
I've tried to watch the runlevel but it looks like it is not working anymore on CentOS 7 as the runlevel is set to 3 all the time.
I've tried to make a service based on this post, I ended up with the following file :
my_service.service
[Unit]
Description=Service to execute on shutdown
After=network.target network-online.target
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/etc/path_to_my_script
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
I've put the follwing line at the beggining of my script:touch /etc/test_shutdown
but the file is never created.
Do you have any idea about how to make this works ?
Thanks for your answers.
centos systemd services shutdown
asked May 29 at 16:00
PopoLeDozo
1
1
for a local filesystem test (or to otherwise ensure that the script can actually be loaded and run from the filesystem) you probably want to copy the freedesktop.org/software/systemd/man/systemd.mount.html dependencies so the appropriate filesystems are there
â thrig
May 29 at 17:16
IâÂÂm not sure if it will work, but try changing theWantedBy=
toshutdown.target
.
â Lucas Werkmeister
Jun 1 at 12:39
add a comment |Â
for a local filesystem test (or to otherwise ensure that the script can actually be loaded and run from the filesystem) you probably want to copy the freedesktop.org/software/systemd/man/systemd.mount.html dependencies so the appropriate filesystems are there
â thrig
May 29 at 17:16
IâÂÂm not sure if it will work, but try changing theWantedBy=
toshutdown.target
.
â Lucas Werkmeister
Jun 1 at 12:39
for a local filesystem test (or to otherwise ensure that the script can actually be loaded and run from the filesystem) you probably want to copy the freedesktop.org/software/systemd/man/systemd.mount.html dependencies so the appropriate filesystems are there
â thrig
May 29 at 17:16
for a local filesystem test (or to otherwise ensure that the script can actually be loaded and run from the filesystem) you probably want to copy the freedesktop.org/software/systemd/man/systemd.mount.html dependencies so the appropriate filesystems are there
â thrig
May 29 at 17:16
IâÂÂm not sure if it will work, but try changing the
WantedBy=
to shutdown.target
.â Lucas Werkmeister
Jun 1 at 12:39
IâÂÂm not sure if it will work, but try changing the
WantedBy=
to shutdown.target
.â Lucas Werkmeister
Jun 1 at 12:39
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f446734%2fmake-http-call-on-system-shutdown-using-systemd-centos-7%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
for a local filesystem test (or to otherwise ensure that the script can actually be loaded and run from the filesystem) you probably want to copy the freedesktop.org/software/systemd/man/systemd.mount.html dependencies so the appropriate filesystems are there
â thrig
May 29 at 17:16
IâÂÂm not sure if it will work, but try changing the
WantedBy=
toshutdown.target
.â Lucas Werkmeister
Jun 1 at 12:39