On 09/16/2015 02:06 PM, Ranjan Maitra wrote:
On Wed, 16 Sep 2015 11:05:36 -0800 Antonio Olivares <wingators(a)inbox.com> wrote:
>
>
>> -----Original Message-----
>> From: maitra.mbox.ignored(a)inbox.com
>> Sent: Tue, 15 Sep 2015 20:12:22 -0500
>> To: users(a)lists.fedoraproject.org
>> Subject: Re: shutdown machine from crontab
>>
>> Hi,
>>
>> Can you try:
>>
>> systemctl poweroff
>>
>> instead of /usr/bin/poweroff and see if that works?
>>
>> Many thanks and best wishes,
>> Ranjan
>>
>
> Ranjan,
>
> Tried it and it does not poweroff machine via crontab. However, from
> $ systemctl poweroff
>
> does poweroff machine. What could be preventing it from shutting down. I will try
the -f option suggested also, then report back.
>
> Best Regards,
>
Sorry, I do not have any idea: you could try /usr/bin/systemctl poweroff but this is
just a random stab...
I'm pretty sure this is caused by the fact that crontab entries don't
have a console associated with them and systemctl wants to spit stuff
out to stdout. You could try redirecting stdout and stderr in your cron
entry:
systemctl poweroff >/dev/null 2>&1
or possibly launch systemctl in a screen session:
screen -S "sysshutdown" -d -m systemctl poweroff
The first MAY work (dunno if systemctl is that picky). The second would
run it in a screen session so it would have a stdin, stdout and stderr.
That is assuming you have screen installed (and why wouldn't you?). If
it failed you could "screen -r" and see what error systemctl is
spitting out.
This is just a guess.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital ricks(a)alldigital.com -
- AIM/Skype: therps2 ICQ: 226437340 Yahoo: origrps2 -
- -
- When all else fails, try reading the instructions. -
----------------------------------------------------------------------