Use systemd-shutdownd schedule

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have multiple Redhat & CentOS 7 servers that are used only during working hours. I am looking into using the systemd-shutdownd service to shut down each machine at 6-30pm on workdays.



Systemd appears to be a cleaner solution than cron jobs.



Google shows that there is a schedule file that this service uses, but I have not been able to find how to implement it.



Also, I'd like a way to stop the auto-powerdown in case I work late on a particular day.







share|improve this question



















  • Sorry for my first message. I've just putted exact solution.
    – Yurij Goncharuk
    Apr 19 at 16:36











  • fwiw systemd-shutdownd is (was) just the backend to the standard shutdown.command. shutdown just lets you schedule one shutdown; it doesn't implement a recurring schedule that will run every day.
    – sourcejedi
    Apr 19 at 20:47














up vote
0
down vote

favorite












I have multiple Redhat & CentOS 7 servers that are used only during working hours. I am looking into using the systemd-shutdownd service to shut down each machine at 6-30pm on workdays.



Systemd appears to be a cleaner solution than cron jobs.



Google shows that there is a schedule file that this service uses, but I have not been able to find how to implement it.



Also, I'd like a way to stop the auto-powerdown in case I work late on a particular day.







share|improve this question



















  • Sorry for my first message. I've just putted exact solution.
    – Yurij Goncharuk
    Apr 19 at 16:36











  • fwiw systemd-shutdownd is (was) just the backend to the standard shutdown.command. shutdown just lets you schedule one shutdown; it doesn't implement a recurring schedule that will run every day.
    – sourcejedi
    Apr 19 at 20:47












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have multiple Redhat & CentOS 7 servers that are used only during working hours. I am looking into using the systemd-shutdownd service to shut down each machine at 6-30pm on workdays.



Systemd appears to be a cleaner solution than cron jobs.



Google shows that there is a schedule file that this service uses, but I have not been able to find how to implement it.



Also, I'd like a way to stop the auto-powerdown in case I work late on a particular day.







share|improve this question











I have multiple Redhat & CentOS 7 servers that are used only during working hours. I am looking into using the systemd-shutdownd service to shut down each machine at 6-30pm on workdays.



Systemd appears to be a cleaner solution than cron jobs.



Google shows that there is a schedule file that this service uses, but I have not been able to find how to implement it.



Also, I'd like a way to stop the auto-powerdown in case I work late on a particular day.









share|improve this question










share|improve this question




share|improve this question









asked Apr 19 at 13:47









Hussain Akbar

51




51











  • Sorry for my first message. I've just putted exact solution.
    – Yurij Goncharuk
    Apr 19 at 16:36











  • fwiw systemd-shutdownd is (was) just the backend to the standard shutdown.command. shutdown just lets you schedule one shutdown; it doesn't implement a recurring schedule that will run every day.
    – sourcejedi
    Apr 19 at 20:47
















  • Sorry for my first message. I've just putted exact solution.
    – Yurij Goncharuk
    Apr 19 at 16:36











  • fwiw systemd-shutdownd is (was) just the backend to the standard shutdown.command. shutdown just lets you schedule one shutdown; it doesn't implement a recurring schedule that will run every day.
    – sourcejedi
    Apr 19 at 20:47















Sorry for my first message. I've just putted exact solution.
– Yurij Goncharuk
Apr 19 at 16:36





Sorry for my first message. I've just putted exact solution.
– Yurij Goncharuk
Apr 19 at 16:36













fwiw systemd-shutdownd is (was) just the backend to the standard shutdown.command. shutdown just lets you schedule one shutdown; it doesn't implement a recurring schedule that will run every day.
– sourcejedi
Apr 19 at 20:47




fwiw systemd-shutdownd is (was) just the backend to the standard shutdown.command. shutdown just lets you schedule one shutdown; it doesn't implement a recurring schedule that will run every day.
– sourcejedi
Apr 19 at 20:47










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










CentOS 7 had systemd init system.



systemd has a good feature which is named as timer. Timer is like service and is intended for starting services at specific time. systemd shutdown system by calling systemd-poweroff service. So it's need to write systemd-poweroff.timer:



$ cat /etc/systemd/system/systemd-poweroff.timer
[Unit]
Description=Poweroff every work day
# Call necessary service
Unit=systemd-poweroff.service

[Timer]
# Power off in working days at 23:00
OnCalendar=Mon,Tue,Wed,Thu,Fri *-*-* 23:00:00

[Install]
WantedBy=timers.target


It's need to do systemctl enable systemd-poweroff.timer and systemctl start systemd-poweroff.timer for enable and run timer. After, timer will be started:



$ systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 14min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Thu 2018-04-19 23:00:00 MSK 3h 34min left n/a n/a systemd-poweroff.timer systemd-poweroff.service

2 timers listed.

Pass --all to see loaded but inactive timers, too.


If you want to disable timer in particular day then it's possible just in case of ordinary systemd service:



# systemctl stop systemd-poweroff.timer
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 12min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service

1 timers listed.
Pass --all to see loaded but inactive timers, too.





share|improve this answer























  • Perfect. Thanks.
    – Hussain Akbar
    Apr 20 at 1:22










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438741%2fuse-systemd-shutdownd-schedule%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










CentOS 7 had systemd init system.



systemd has a good feature which is named as timer. Timer is like service and is intended for starting services at specific time. systemd shutdown system by calling systemd-poweroff service. So it's need to write systemd-poweroff.timer:



$ cat /etc/systemd/system/systemd-poweroff.timer
[Unit]
Description=Poweroff every work day
# Call necessary service
Unit=systemd-poweroff.service

[Timer]
# Power off in working days at 23:00
OnCalendar=Mon,Tue,Wed,Thu,Fri *-*-* 23:00:00

[Install]
WantedBy=timers.target


It's need to do systemctl enable systemd-poweroff.timer and systemctl start systemd-poweroff.timer for enable and run timer. After, timer will be started:



$ systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 14min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Thu 2018-04-19 23:00:00 MSK 3h 34min left n/a n/a systemd-poweroff.timer systemd-poweroff.service

2 timers listed.

Pass --all to see loaded but inactive timers, too.


If you want to disable timer in particular day then it's possible just in case of ordinary systemd service:



# systemctl stop systemd-poweroff.timer
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 12min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service

1 timers listed.
Pass --all to see loaded but inactive timers, too.





share|improve this answer























  • Perfect. Thanks.
    – Hussain Akbar
    Apr 20 at 1:22














up vote
1
down vote



accepted










CentOS 7 had systemd init system.



systemd has a good feature which is named as timer. Timer is like service and is intended for starting services at specific time. systemd shutdown system by calling systemd-poweroff service. So it's need to write systemd-poweroff.timer:



$ cat /etc/systemd/system/systemd-poweroff.timer
[Unit]
Description=Poweroff every work day
# Call necessary service
Unit=systemd-poweroff.service

[Timer]
# Power off in working days at 23:00
OnCalendar=Mon,Tue,Wed,Thu,Fri *-*-* 23:00:00

[Install]
WantedBy=timers.target


It's need to do systemctl enable systemd-poweroff.timer and systemctl start systemd-poweroff.timer for enable and run timer. After, timer will be started:



$ systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 14min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Thu 2018-04-19 23:00:00 MSK 3h 34min left n/a n/a systemd-poweroff.timer systemd-poweroff.service

2 timers listed.

Pass --all to see loaded but inactive timers, too.


If you want to disable timer in particular day then it's possible just in case of ordinary systemd service:



# systemctl stop systemd-poweroff.timer
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 12min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service

1 timers listed.
Pass --all to see loaded but inactive timers, too.





share|improve this answer























  • Perfect. Thanks.
    – Hussain Akbar
    Apr 20 at 1:22












up vote
1
down vote



accepted







up vote
1
down vote



accepted






CentOS 7 had systemd init system.



systemd has a good feature which is named as timer. Timer is like service and is intended for starting services at specific time. systemd shutdown system by calling systemd-poweroff service. So it's need to write systemd-poweroff.timer:



$ cat /etc/systemd/system/systemd-poweroff.timer
[Unit]
Description=Poweroff every work day
# Call necessary service
Unit=systemd-poweroff.service

[Timer]
# Power off in working days at 23:00
OnCalendar=Mon,Tue,Wed,Thu,Fri *-*-* 23:00:00

[Install]
WantedBy=timers.target


It's need to do systemctl enable systemd-poweroff.timer and systemctl start systemd-poweroff.timer for enable and run timer. After, timer will be started:



$ systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 14min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Thu 2018-04-19 23:00:00 MSK 3h 34min left n/a n/a systemd-poweroff.timer systemd-poweroff.service

2 timers listed.

Pass --all to see loaded but inactive timers, too.


If you want to disable timer in particular day then it's possible just in case of ordinary systemd service:



# systemctl stop systemd-poweroff.timer
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 12min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service

1 timers listed.
Pass --all to see loaded but inactive timers, too.





share|improve this answer















CentOS 7 had systemd init system.



systemd has a good feature which is named as timer. Timer is like service and is intended for starting services at specific time. systemd shutdown system by calling systemd-poweroff service. So it's need to write systemd-poweroff.timer:



$ cat /etc/systemd/system/systemd-poweroff.timer
[Unit]
Description=Poweroff every work day
# Call necessary service
Unit=systemd-poweroff.service

[Timer]
# Power off in working days at 23:00
OnCalendar=Mon,Tue,Wed,Thu,Fri *-*-* 23:00:00

[Install]
WantedBy=timers.target


It's need to do systemctl enable systemd-poweroff.timer and systemctl start systemd-poweroff.timer for enable and run timer. After, timer will be started:



$ systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 14min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Thu 2018-04-19 23:00:00 MSK 3h 34min left n/a n/a systemd-poweroff.timer systemd-poweroff.service

2 timers listed.

Pass --all to see loaded but inactive timers, too.


If you want to disable timer in particular day then it's possible just in case of ordinary systemd service:



# systemctl stop systemd-poweroff.timer
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 2018-04-19 19:39:36 MSK 12min left n/a n/a systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service

1 timers listed.
Pass --all to see loaded but inactive timers, too.






share|improve this answer















share|improve this answer



share|improve this answer








edited Apr 24 at 22:18









sourcejedi

18.4k32475




18.4k32475











answered Apr 19 at 14:19









Yurij Goncharuk

2,2582521




2,2582521











  • Perfect. Thanks.
    – Hussain Akbar
    Apr 20 at 1:22
















  • Perfect. Thanks.
    – Hussain Akbar
    Apr 20 at 1:22















Perfect. Thanks.
– Hussain Akbar
Apr 20 at 1:22




Perfect. Thanks.
– Hussain Akbar
Apr 20 at 1:22












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f438741%2fuse-systemd-shutdownd-schedule%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay