Recent

Author Topic: Linux shut-down - How to?  (Read 4962 times)

KarenT

  • Full Member
  • ***
  • Posts: 120
Linux shut-down - How to?
« on: July 22, 2017, 01:27:33 am »
Hello,

Is there some command I can issue to shut down Ubuntu after a lengthy process has been started? I can set a program running but about an hour later I have to go in and turn off the PC.

I'd like it to be able to turn the PC off when the process has completed. I had a windows routine in Delphi, but not sure where it is right now, but seriously doubt it would do any good in Ubuntu anyway.

Is it possible? Searching has not turned up anything useful to Linux yet.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Linux shut-down - How to?
« Reply #1 on: July 22, 2017, 01:38:09 am »
Hello,

Is there some command I can issue to shut down Ubuntu after a lengthy process has been started? I can set a program running but about an hour later I have to go in and turn off the PC.

I'd like it to be able to turn the PC off when the process has completed. I had a windows routine in Delphi, but not sure where it is right now, but seriously doubt it would do any good in Ubuntu anyway.

Is it possible? Searching has not turned up anything useful to Linux yet.

Probably a number of ways to approach this.

Here's a list of all the bash commands you can use on Linux. Note shutdown. Try putting it at the end of a bash script that starts your process.

https://ss64.com/bash/

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Linux shut-down - How to?
« Reply #2 on: July 22, 2017, 02:18:28 am »
Code: Pascal  [Select][+][-]
  1. uses Unix;
  2. procedure shutdown;
  3. begin
  4.   fpSystem('/sbin/shutdown -P now');
  5. end;
  6.  
works like a charm in suse with a user with admin privileges in case your user is a restricted user use sudo just  like any console command just don't share your password with the world (aka avoid public source control servers for this code)
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

KarenT

  • Full Member
  • ***
  • Posts: 120
Re: Linux shut-down - How to?
« Reply #3 on: July 22, 2017, 03:31:01 pm »
Thank you to you both.

@taazz:
I will try your suggestion first as it looks more than simple enough and may work for what I need. The program is for my own use so not a lot of risk involved.

@phil:
Thanks for the link, I had no idea there were so many commands in Bash.

KarenT

  • Full Member
  • ***
  • Posts: 120
Re: Linux shut-down - How to?
« Reply #4 on: July 22, 2017, 11:32:02 pm »
Code: Pascal  [Select][+][-]
  1.   fpSystem('/sbin/shutdown -P now');
  2.  

Working fine for Ubuntu 14.04 too. Thanks. I had to add "sudo" to it, but does just what I need for my backups.

 

TinyPortal © 2005-2018