Set timing shutdown function

Suggest new features here
Post Reply
BH8SXD
Posts: 6
Joined: Thu Apr 12, 2018 6:46 am
Location: OL14jv
Contact:

Set timing shutdown function

Post by BH8SXD » Mon Jan 14, 2019 6:18 am

The system can do a custom timing shutdown function.
Happy every day! ! !

AF6VN
Posts: 105
Joined: Fri Jul 20, 2018 1:15 am

Re: Set timing shutdown function

Post by AF6VN » Mon Jan 14, 2019 8:36 pm

Explain what you mean, that isn't handled by "sudo shutdown..."?
NAME
shutdown - Halt, power-off or reboot the machine

SYNOPSIS
shutdown [OPTIONS...] [TIME] [WALL...]

DESCRIPTION
shutdown may be used to halt, power-off or reboot the machine.

The first argument may be a time string (which is usually "now"). Optionally, this may
be followed by a wall message to be sent to all logged-in users before going down.

The time string may either be in the format "hh:mm" for hour/minutes specifying the
time to execute the shutdown at, specified in 24h clock format. Alternatively it may
be in the syntax "+m" referring to the specified number of minutes m from now. "now"
is an alias for "+0", i.e. for triggering an immediate shutdown. If no time argument
is specified, "+1" is implied.

Note that to specify a wall message you must specify a time argument, too.

If the time argument is used, 5 minutes before the system goes down the /run/nologin
file is created to ensure that further logins shall not be allowed.

--
AF6VN
Dennis L Bieber

BH8SXD
Posts: 6
Joined: Thu Apr 12, 2018 6:46 am
Location: OL14jv
Contact:

Re: Set timing shutdown function

Post by BH8SXD » Thu Jan 17, 2019 4:50 am

Yes, I have set up a time auto-shutdown function. I failed to edit it using the sudo crontab -e command and in Expert Editors of pi-star. May I ask where I did it wrong?
Attachments
20190117124938.jpg
20190117124938.jpg (71.62 KiB) Viewed 199 times
Happy every day! ! !

AF6VN
Posts: 105
Joined: Fri Jul 20, 2018 1:15 am

Re: Set timing shutdown function

Post by AF6VN » Thu Jan 17, 2019 6:50 pm

Well... one could emphasize what you stated --
failed to edit it using the sudo crontab -e command

Code: Select all

DESCRIPTION
       crontab is the program used to install, deinstall or list the tables used to drive the
       cron(8) daemon in Vixie Cron.  Each user can have their own crontab, and though  these
       are files in /var/spool/cron/crontabs, they are not intended to be edited directly.

Code: Select all

       The -e option is used to edit the current crontab using the editor  specified  by  the
       VISUAL  or EDITOR environment variables.  After you exit from the editor, the modified
       crontab will be installed automatically. If neither of the  environment  variables  is
       defined, then the default editor /usr/bin/editor is used.
{Unfortunately when using "code" to keep the fixed space formatting, one can not apply bold/etc. Key points are
they are not intended to be edited directly.
After you exit from the editor, the modified crontab will be installed automatically.
}

Editing without using the command does not "install" the scheduled command (a reboot might do it, however).

The second aspect, at least as I see it, is that there is no command "root" on the system, so the command line is invalid. As the hint line shows, the fields are:
Minute in the hour
Hour of the day
Day of month
Month
Day of week
Command to execute

You've specified 44th minute of 13th hour, any day/month, and a command line of "root /sbin/shutdown -h now"

You'd likely be better off to use:

sudo su
crontab -e

to enter the command into the root privilege cron file (avoiding the need for a user cron file to activate root privileges).

Furthermore, since one can specify a time on the shutdown command itself, one only needs to execute the command once during bootup. A cron job may not be needed.

shutdown -h 13:44

I'll admit I'm not familiar with setting up one-shot execution during boot; I'd likely follow option #3 at https://smallbusiness.chron.com/run-com ... 27796.html Though a crontab entry of

@reboot shutdown -h 13:44

may be easier -- just remember to edit as root using the crontab editor command so the changes are installed

--
AF6VN
Dennis L Bieber

BH8SXD
Posts: 6
Joined: Thu Apr 12, 2018 6:46 am
Location: OL14jv
Contact:

Re: Set timing shutdown function

Post by BH8SXD » Tue Jan 29, 2019 7:36 am

Ok, thank you very much. I'll try again
Happy every day! ! !

Post Reply