LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-31-2020, 05:49 PM   #16
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757

Quote:
Originally Posted by Hermani View Post
Maybe I am just a fan of simple solutions. But I am still a n--b as well..

What is wrong with something like

Code:
> command_to_run && shutdown now
Mainly two issues here. First, as has already been previously stated, the shutdown must be issued as root, while the command_to_run is issued as normal user. Your solution does not address that.

Second, as I understand it, OP wants to shutdown after the job finishes. Your solution will only execute shutdown if the job finishes successfully, i.e., if the first command fails for some reason then the machine will not shutdown.
 
1 members found this post helpful.
Old 06-01-2020, 04:12 PM   #17
Hermani
Member
 
Registered: Apr 2018
Location: Delden, NL
Distribution: Ubuntu
Posts: 261
Blog Entries: 3

Rep: Reputation: 113Reputation: 113
Quote:
Originally Posted by crts View Post
Second, as I understand it, OP wants to shutdown after the job finishes. Your solution will only execute shutdown if the job finishes successfully, i.e., if the first command fails for some reason then the machine will not shutdown.
Thanks. You're right; however I did not know that if the first command does not exit succesfully. the second does not run.
 
Old 06-01-2020, 07:59 PM   #18
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,679

Rep: Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713
Quote:
Originally Posted by Hermani View Post
Thanks. You're right; however I did not know that if the first command does not exit succesfully. the second does not run.
Seek documentation of the meaning and behavior of && for details. Your solution is not wrong, but it may not have the behavior that the OP desires (or described).
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Spectre and Meltdown: Explanation, Info, What's being done, What can be done Zyblin Linux - Security 7 02-17-2018 09:48 PM
what is the default powerstate (e.g. S3,S4,S5) for the command 'shutdown -hP' or 'shutdown -hH' or 'shutdown -h' badbetty Slackware 6 11-12-2017 12:18 AM
FC18: running a command on shutdown (or reboot) before every other shutdown operation P5music Fedora 3 04-23-2013 03:56 PM
'shutdown' command causing unclean shutdown silentwol Linux - Software 3 07-01-2009 02:01 AM
suse 10.0 => processes "sending kill signal": "done, done, missing"...!? ungua Linux - Newbie 2 01-18-2006 10:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration