We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

How to schedule shutdown of the Jolla ? [answered]

asked 2016-05-16 16:13:57 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2018-12-03 21:28:46 +0300

Tanghus gravatar image

Hi,

I want my Jolla to automaticaly shutdown at 11 PM and power on at 7 AM.

I've just tried the crontab to schedule a shutdown at 3PM, but it didn't work :

$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.2836 installed on Mon May 16 15:08:04 2016)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
10 15 * * * /usr/sbin/shutdown -h now

Can you help ?

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by SebM
close date 2016-05-17 14:17:55.596581

Comments

Maybe it needs to be run as root instead of normal user?

avhakola ( 2016-05-16 16:22:21 +0300 )edit

I've just tried with root, it did'nt work either :

[root@Jolla ~]# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.7377 installed on Mon May 16 15:29:51 2016)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
30 15 * * * poweroff
SebM ( 2016-05-16 16:31:50 +0300 )edit

Did you insert a blank line at the end of the crontab-file?

MichaelS ( 2016-05-16 16:59:17 +0300 )edit
1

The command to 'poweroff' is actually shutdown.

If you open Terminal, type in shutdown -h 15:00 - the device will 'poweroff' at 3pm.

The shutdown command has its own built in scheduler.

Spam Hunter ( 2016-05-16 16:59:42 +0300 )edit

This didn't work with the shutdown command either :

$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.1838 installed on Mon May 16 18:02:29 2016)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
3 18 * * * /usr/sbin/shutdown -h now
SebM ( 2016-05-16 19:03:58 +0300 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2016-05-17 14:17:27 +0300

SebM gravatar image

updated 2016-05-17 14:18:24 +0300

Thanks to juiceme, the shutdown pb. is solved, so I'm using the following crontab for nemo :

$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.2019 installed on Tue May 17 13:09:53 2016)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
0 23 * * * /usr/sbin/dsmetool --shutdown
edit flag offensive delete publish link more

Comments

Why not using systemd timers ? Seems to me more logical on a systemd-powered OS.

DrYak ( 2016-05-17 21:02:45 +0300 )edit

@DrYak: I didn't know that SailFish was a systemd-powered OS, can you help me translat my crontab to a systemd timer ?

SebM ( 2016-05-17 22:42:34 +0300 )edit
4

Here's the sysmted equivalent:

[Unit]
Description=Timer to schedule shutdown  of the Jolla
[Timer]
OnCalendar=23:00
AccuracySec=1usec

accuracy is used to schedule several timer happening all at the same time. systemd will avoid launching them all at the same time and will instead launch one after the other, each launch being at worst within "AccuracySec" from desired time.

(i.e.: One can set all the maintenance to be 10 min after boot with "BootSec" and systemctl will avoid launching all the scripts simultaneously. It's the equivalent of putting irregular times in a crontab (e.g.: putting a hourly job at "52" minutes, to avoid it running together with other jobs) )

If there's another time that you desperatly need to have happening at exactly 23:00, and can wait the shutdown to happen at 23:05, then put: AccuracySec=5min

Once it gets implemented correctly, one could use WakeSystem=true for the opposite (for waking up the system to perform a task). I haven't tested if its supported on Jolla yet.

Then there's the corresponding service:

[Unit]
Description=Shutdown of the Jolla

[Service]
Type=oneshot
ExecStart=/usr/sbin/dsmetool --shutdown

oneshot type are for service where one command eventually finish (like your shutting down of the jolla) as opposed of services that leave a daemon running in the background (say: a file server), thus systemd knows that its normal for the service not to start.

You can then put your files in:

${HOME}/.config/systemd/user/{timer}.timer and
${HOME}/.config/systemd/user/{timer}.service

(note that for ease of configuration, both timer and service should have the same name. It's also possible to use different names, if you specify the service in the timer file)

Then enable the timer with:

systemctl --user start{timer}.timer

You can check the timer with :

systemctl --user list-timers

It will indicate how much time is left until the next timer.

DrYak ( 2016-05-17 23:24:50 +0300 )edit

@DrYak Thanks for this tutorial. I can see more clearly now what you are taking about. Btw : The command systemctl --user list-timers is not available in systemd-208-1.8.1.armv7hl package

SebM ( 2016-05-18 13:51:12 +0300 )edit

@DrYak, the "WakeSystem=true" option doesn't work on Jolla, as far as I know...

Schturman ( 2016-05-18 23:39:22 +0300 )edit

Question tools

Follow
6 followers

Stats

Asked: 2016-05-16 16:13:57 +0300

Seen: 739 times

Last updated: May 17 '16