Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello.
How can I shutdown my system via "shutdown" command in specific Date and Time? I know that with "shutdown -h " I can specific a hours but how about Date?
For example, I want to shutdown my system at 23:00 tomorrow.
In addition for the date you can specify the day of the week i.e thu (4) or day of the month i.e 9. Tomorrow being Thursday and the ninth day of the March.
It is also possible to use the date command for a specific date.
shutdown may be used to halt, power-off or reboot the machine.
The first argument may be a time string (which is usually "now").
Yes, but it goes on to say:
Code:
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.
The OP wants to shutdown with a specific date and time (and I'm sure doesn't want to have to calculate how many minutes ahead that particular date/time is).
Try the 'at' cmd; its good for one shot deals. For regular ones, cron is popular.
I never set up cron to reboot or shutdown a machine, but I do use 'at' for this purpose often.
Example:
Code:
echo "shutdown -r now" | at 23:59
Check the man page and online examples linked in other postings here for ways to express exact dates and times for the 'at' command. This is a very useful technique.
I never set up cron to reboot or shutdown a machine, but I do use 'at' for this purpose often.
Example:
Code:
echo "shutdown -r now" | at 23:59
Check the man page and online examples linked in other postings here for ways to express exact dates and times for the 'at' command. This is a very useful technique.
A couple of reasons:
1. I can control at both remotely and on the terminal easier, in the case I change my mind.
2. This works the same on all of my machines, while some of them have 'shutdown' commands that specify parameters differently.
I am used to running a mixed bag of RHEL, CentOS, Debian, SUSE, Ubuntu Server, AIX, HP-UX, Tru64Unix, and a couple less usual. (No more SCO, thank goodness!) The versions are all over the place, and some of them implement 'shutdown' as an executable, others as scripts. I had created a local manual of the "things that work everywhere except Windows" at my last workplace: this was one item in that document.
There is not likely to be any good reason for avoiding the form above as long as you are running any currently supported Linux version with near standard GNU utilities. I would just check your local man pages first, to be sure your environment is one where that does what you want. I HATE dragging a newbie into version limbo or giving advice that fails them. I figure they (mostly) deserve better from me. And that is all there is about that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.