Page 1 of 1

waking from suspend, then shutting down

Posted: Mon Mar 08, 2021 3:35 pm
by Linuxgrrl
My system is set up to suspend when not needed, then wake for recordings. It does a good job at both.
The problem is when I want to actually use the computer, as it doubles as my daily machine. Lately when I try to wake it from suspend so I can write some email or whatever, it puts itself back to sleep after a minute. I think myth is doing it, because the backend log says:

Code: Select all

Mar  8 10:24:27 mythbox mythbackend: mythbackend[12550]: I CoreContext platforms/mythpowerdbus.cpp:530 (AcquireLock) PowerDBus: Failed to delay sleep,shutdown: Permission denied
Mythbackend is running as user mythtv, which I believe is the correct way to do it, yes?

Code: Select all

mary@mythbox:~$ ps aux | grep mythb

mythtv      1183  1.4  1.3 4192216 111556 ?      Ssl  10:29   0:04 /usr/bin/mythbackend --quiet --syslog local7
What do I need to change so that mythbackend can "delay shutdown"?

Re: waking from suspend, then shutting down

Posted: Mon Mar 08, 2021 4:50 pm
by gedakc
My MythTV PVR uses MythWelcome to handle automatically shutting down when not busy and powering up to record shows.

To prevent the PVR from shutting down I use the command:

Code: Select all

mythshutdown --lock
To enable the PVR to resume that ability to automatically shutdown I use the command:

Code: Select all

mythshutdown --unlock
This ability can also be accessed from the MythWelcome screen by pressing "M" for menu to lock/unlock shutdown. I have an MCE Remote Control and the menu can be accessed by pressing the green windows flag icon button.

Re: waking from suspend, then shutting down

Posted: Mon Mar 08, 2021 5:37 pm
by Linuxgrrl
Interesting! I use the script from the wiki, which checks for activity by other users before shutting down. It took a bit of effort to get it to work, but it’s been reliable until recently. I guess I could try mythwelcome but is there a simple thing I am missing with my existing setup?

Re: waking from suspend, then shutting down

Posted: Mon Mar 08, 2021 6:31 pm
by gedakc
The MythTV wiki has lots of information in various places. Which "script from the wiki" are you using?

If the script already checks for activity, then you might try to identify a process that is running when you are using the computer, and is not running when you log out. Then add a check for that process to the script.

One way to check in a shell script for a running process, such as a KDE konsole terminal window is:

Code: Select all

if pidof konsole 1> /dev/null; then
	echo "At least one process named konsole is running."
fi
'Hope that helps.

Re: waking from suspend, then shutting down

Posted: Mon Mar 08, 2021 7:44 pm
by pgbennett
In mythtv-setup ->General->shutdown/wakeup options->pre-shutdown check command put the name os a script that returns 1 to prevent shutdown, 0 to allow shutdown.

You can use something like the check for konsole above. Add "exit 1" if the process is running.

Re: waking from suspend, then shutting down

Posted: Mon Mar 15, 2021 12:19 am
by Linuxgrrl
Getting back belatedly here ...

Code: Select all

The MythTV wiki has lots of information in various places. Which "script from the wiki" are you using?
I adopted the script called checklogin.sh that tells myth whether it is safe to shut down.
The script requires all users logged out to permit auto shutdown. Thus, when I wish to manually wake the machine, the first thing I do is try to log in. This used to work fine. Now, it seems, the machine is shutting back down while I am in process of inputting my password to log in, or within about 30 seconds thereafter.

Is the permission error

Code: Select all

Failed to delay sleep,shutdown: Permission denied
relevant?

Answering your other point, it sounds like a good idea to identify a process and check for it. It appears that I need a process that runs when the machine wakes up (before I log in), but that stops when I log out (so that the machine can go to sleep). I'm having trouble with what that could be.

Re: waking from suspend, then shutting down

Posted: Mon Mar 15, 2021 1:17 pm
by pgbennett
Try setting idle shutdown timeout to at least 300 (5 minutes) to allow time to logon before it shuts down.

Re: waking from suspend, then shutting down

Posted: Mon Mar 15, 2021 1:19 pm
by pgbennett
The permission denied may be the wrong permission on the pre-shutdown check command. Is it marked executable by all?

Re: waking from suspend, then shutting down

Posted: Mon Mar 15, 2021 2:19 pm
by bill6502
@Linuxgrrl, check the timestamp of the message and see if it matches the time
you're attempting the checklogin (I suspect not.) Also the message is informational,
note the " I " in the message.

The full message (which only occurs once early in the startup sequence) in my logs looks like:

Code: Select all

2021-03-14 11:14:00.934467 I [8738/8738] CoreContext platforms/mythpowerdbus.cpp:539 (AcquireLock) - PowerDBus: Failed to delay sleep,shutdown: Permission denied
Ref: https://code.mythtv.org/cgit/mythtv/tre ... s.cpp#n536

Re: waking from suspend, then shutting down

Posted: Mon Mar 15, 2021 3:55 pm
by Linuxgrrl
Thanks all. A couple of updates:
1. I checked and the checklogin.sh script is executable by all.
2. Idle shutdown timeout was already set to 300 seconds

As far as the permission error, I'll have to double check whether it syncs with the improper shutdown. I was pretty sure it did, but I haven't been letting the machine automatically shut down the past couple days, because I'm afraid of corrupting my mythconverg database by forcing the machine back up again with a power cycle.

In the meantime I am going to check the box for "Block shutdown before client connected" and see if that helps.

Re: waking from suspend, then shutting down

Posted: Mon Mar 15, 2021 8:20 pm
by bill6502
You can do systemctl cat mythtv-backend.service or just get specific properties
to see if ADDITIONAL_ARGS is in play:

Code: Select all

systemctl --no-pager show --property=ExecStart,EnvironmentFiles mythtv-backend.service
ExecStart={ path=/usr/local/bin/mythbackend ; argv[]=/usr/local/bin/mythbackend --logpath /var/log/mythtv --override-setting libCECEnabled=0 --quiet $ADDITIONAL_ARGS  ; ignore_errors=no ; start_time=[Mon 2021-03-15 11:11:58 CDT] ; stop_time=[n/a] ; pid=21352 ; code=(null) ; status=0/0 }
EnvironmentFiles=/etc/mythtv/additional.args (ignore_errors=yes)
If so, then in a file like /etc/mythtv/additional.args above, add (or create the file and add) a line like:
ADDITIONAL_ARGS="-v system:debug,idle", then restart the backend and see what the return code
is when the new script is called and note the idle log entries.