> -----Original Message-----
> From: ed.gres...@greshko.com
> Sent: Thu, 17 Sep 2015 05:45:17 +0800
> To: users@lists.fedoraproject.org
> Subject: Re: shutdown machine from crontab
> 
> On 09/17/15 03:05, Antonio Olivares wrote:
>> 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.
> 
> If you were to ssh into the machine and enter "systemctl poweroff" or
> "/usr/bin/poweroff" you'd find that it would prompt you for a password.
> This is the same thing that is happening when using the crontab, but of
> course you can't supply the password in that case.
> 
> One option, if you don't want to use root's crontab, would be to make an
> entry in the sudoers file to allow you to use the poweroff command via
> sudo without supplying a password.

Ranjan, Rick and Ed 

Thank you for your input.  I used the -f option with 

[olivares@localhost ~]$ crontab -l
# min  hour day-of-month month day-of-week command
# 0-59 0-23     1-31     1-12  0-6 0=sun 1=mon 
43 09 * * 1-5 ~/.dalarm >/dev/null 2>&1
33 10 * * 1-5 ~/.dalarm >/dev/null 2>&1
23 11 * * 1-5 ~/.dalarm >/dev/null 2>&1
13 12 * * 1-5 ~/.dalarm >/dev/null 2>&1
53 13 * * 1-5 ~/.dalarm >/dev/null 2>&1
43 14 * * 1-5 ~/.dalarm >/dev/null 2>&1
33 15 * * 1-5 ~/.dalarm >/dev/null 2>&1
33 16 * * 1-5 ~/.lalarm >/dev/null 2>&1
#10 17 * * 1-5 /usr/sbin/poweroff >/dev/null 2>&1
#20 17 * * 1-5 systemctl poweroff -f >/dev/null 2>&1

[olivares@localhost ~]$ 
To test the shutdown I used 

10 17 * * 1-5 /usr/sbin/poweroff -f >/dev/null 2>&1
and 
with 
20 17 * * 1-5 systemctl poweroff -f >/dev/null 2>&1

and none of these worked.  I gave up and set this up as root and machine does 
shutdown.  I wonder where Fedora changed things, it just worked TM, but now it 
does not.  From your message Ed, I get that I would need to type a password, 
but if I issue the command(s) from terminal the machine shuts down and does not 
prompt me for anything.  I was thinking also about /etc/cron.deny but one can 
do pretty much anything most were working except shutdown :(

I created a file ~/.shutdown with the following:

[olivares@localhost ~]$ cat .shutdown
#!/bin/sh

/usr/sbin/poweroff -f >/dev/null 2>&1 #systemctl poweroff -f >/dev/null 2>&1


[olivares@localhost ~]$
and called it within crontab, but it also failed to shutdown the machine.  


[olivares@localhost ~]$ cat /etc/fedora-release 
Fedora release 22 (Twenty Two)
[olivares@localhost ~]$ uname -a
Linux localhost.localdomain 4.1.6-201.fc22.x86_64 #1 SMP Fri Sep 4 17:49:24 UTC 
2015 x86_64 x86_64 x86_64 GNU/Linux
[olivares@localhost ~]$

The permanent solution is to use root:

[olivares@localhost ~]$ su -
Password: 
[root@localhost ~]# crontab -l
58 21 * * 1-5 /sbin/poweroff > /dev/null 2>&1 

[root@localhost ~]# 
and machine shuts down automagically at 9:58 pm at night :)  

Best Regards,


Antonio A. Olivares

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!
Check it out at http://www.inbox.com/marineaquarium


-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org

Reply via email to