Sleep timer

I am trying to set up my system so that it will sleep (suspend) at 22:30 every night.

I have written the follow script:

#!/bin/bash

dbus-send --print-reply \
            --system \
            --dest=org.freedesktop.UPower \
            /org/freedesktop/UPower \
            org.freedesktop.UPower.Suspend
            

and saved it as /home/steve/bin/sleep.sh. If I execute this from the command line it works.

I have written the following crontab:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXQM14 installed on Thu Aug 16 21:03:25 2012)
# (Cronie version 4.2)
30 22 * * * /home/steve/bin/sleep.sh > /home/steve/cron.txt 2>&1

When this executes, it leaves the following error message:

Error org.freedesktop.UPower.GeneralError: not authorized

What am I missing?

openSUSE 12.1 x86_64 KDE 4.8

On 2012-08-17 03:16, evetsnameloc wrote:
>
> I am trying to set up my system so that it will sleep (suspend) at 22:30
> every night.
>
> I have written the follow script:

There are two commands to directly suspend/hibernate a machine: pm-hibernate or pm-suspend
(needs being root), or powersave -U or -u that runs as user if user is allowed.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

You miss authorisation.

You might think that is a bit stupid to answer, but it is what you asked for.

Shutting dow the system (all variants of course. including hibernation, etc.) is typicaly a superuser task (what, when all end-users could do that at will?). Now it could be that a (or more) desktop user(s) are allowed to do this via the freedesktop.org mechanism. But when you run a script in the background, there is no desktop at all.

Actually, I ended up writing a root-level crontab that uses pm-suspend and this works. I was just trying to find a way to do this without having to be root.

Not stupid at all, and in fact makes a lot of sense. Thanks.

evetsnameloc wrote:
>
> robin_listas;2480423 Wrote:
>> There are two commands to directly suspend/hibernate a machine:
>> pm-hibernate or pm-suspend
>> (needs being root), or powersave -U or -u that runs as user if user is
>> allowed.
>
> Actually, I ended up writing a root-level crontab that uses pm-suspend
> and this works. I was just trying to find a way to do this without
> having to be root.

You can configure your user to be able to run pm-suspend without
password in sudoers.

Better yeet: YaST > Sudoers.

Vahis

http://waxborg.servepics.com
openSUSE 11.4 (x86_64) 2.6.37.6-0.20-default main host
openSUSE 12.1 (x86_64) 3.4.8-1-desktop Tumbleweed in VirtualBox
openSUSE 12.1 (i586) 3.1.10-1.16-desktop in EeePC 900