You are not logged in.
Hi!
I am trying to figure out how to schedule poweroff every monday to friday at 5 AM and then I will set a poweron schedule in bios at 9 AM. I think this can be done with a cron job but I want to do it in modern systemd way. I need to reduce power draw in mornings and my quad socket opteron server could save some power then by shutdown.
I guess I need a systemd timer
https://wiki.archlinux.org/index.php/Sy … eplacement
And use systemd-shutdownd.service
https://utcc.utoronto.ca/~cks/space/blo … OfShutdown
But not sure how to pull everything together.
So I am asking for some friendly hints.
Thanks!
Offline
For each .timer file, a matching .service file exists (e.g. foo.timer and foo.service). The .timer file activates and controls the .service file. The .service does not require an [Install] section as it is the timer units that are enabled. If necessary, it is possible to control a differently-named unit using the Unit= option in the timer's [Timer] section.
If I am not entirely mistaken, this is the answer you are looking for.
Offline
Well yes, you need a a timer file and a service file.
So for the timer you want something like this
# /etc/systemd/system/poweroff.timer
[Unit]
Description=Poweroff maschine at 5 AM Mo-Fri
[Timer]
OnCalendar=Mon..Fri *-*-* 05:00:00
Persistent=true
[Install]
WantedBy=timers.target
and create the suiteable service file
# /etc/systemd/system/poweroff.service
[Unit]
Description = Poweroff maschine at 5 AM Mo-Fri
[Service]
Type=oneshot
ExecStart=/usr/bin/poweroff
Enable the timer with
# systemctl enable /etc/systemd/system/poweroff.timer
Last edited by r4ptor (2018-03-06 11:05:44)
Offline