CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

automatic shut down the PC after ending of run

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree6Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   August 29, 2013, 18:12
Default automatic shut down the PC after ending of run
  #1
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
Hi
is there a script or utility so that turn off the computer after end of run automatically?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 30, 2013, 03:11
Default
  #2
Senior Member
 
Join Date: Mar 2010
Location: Germany
Posts: 140
Rep Power: 8
cutter is on a distinguished road
Hi,

in case you're doing single serial runs a simple
Code:
sudo shutdown now
should do the trick. For the case of parallel MPI runs I'm searching for an adequate solution myself.

cutter
cutter is offline   Reply With Quote

Old   August 30, 2013, 03:18
Default
  #3
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
Hi
I want a complete script that turn off the PC when the run ended automatically not manual.
then please let me know in parallel cases.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 30, 2013, 03:29
Default
  #4
Senior Member
 
Join Date: Mar 2010
Location: Germany
Posts: 140
Rep Power: 8
cutter is on a distinguished road
Oh sorry,

what I meant is running your simulation like this
Code:
$SOLVER && sudo shutdown now
. This still doesn't work with mpirun that forks multiple solver processes.
immortality likes this.
cutter is offline   Reply With Quote

Old   August 31, 2013, 08:29
Default
  #5
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,648
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings to all!

@cutter: Sorry, but I think you forgot that sudo will ask for the password after several minutes of not having used sudo. So, no, that won't work
In addition, the "&&" implies that the command on the right to it should only be executed if the one on the left finished with success, which might not be the case. It would be a bit annoying if the solver crashed after 30min of falling asleep and the computer stayed on all night


WARNING: The following instructions can lead to accidental shutdowns, and respective consequences, when they are not intended! Therefore, use these instructions at your own risk!

  1. Read the instructions for using shutdown.
    Code:
    man shutdown
    If you do not read+study the instructions carefully, don't expect me to help you recover lost work
  2. Now, at least once, you'll have to change the permissions for the command shutdown, so that the user can use the command without sudo:
    Code:
    sudo chmod +s $(which shutdown)
    To remove such permissions, run:
    Code:
    sudo chmod -s $(which shutdown)
    Note: These commands should be performed manually, not automatically, because they rely on sudo.
  3. I advise you to not use the "now" option, because the run may take longer than expected and it might still be running in the morning. My advice is to give it 5 to 15 minutes before shutting down:
    Code:
    shutdown +5
    If you ask why the "+5", then that just means you did not do step #1.
  4. With this delay for the shutdown, keep in mind that the "-c" option can abort the shutdown:
    Code:
    shutdown -c
    This way, in the morning, you can run this command to override the shutdown request.
  5. As for adding this to a script... it's a command, it works like all other commands in scripts.
Best regards,
Bruno
cutter and immortality like this.
__________________
wyldckat is offline   Reply With Quote

Old   August 31, 2013, 09:17
Default
  #6
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
Hi Bruno thanks
I didn't grasp how to use the command exactly.for example :"rhoCentralFoam && shutdown +5" is true or not use &&? like: "rhoCentralFoam shutdown +5"
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 31, 2013, 09:22
Default
  #7
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,648
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Quote:
Originally Posted by wyldckat View Post
5. As for adding this to a script... it's a command, it works like all other commands in scripts.
Sorry, I should have written that shutdown is an application like all other applications. For example, the cavity tutorial case:
Code:
blockMesh
icoFoam
shutdown +5
__________________
wyldckat is offline   Reply With Quote

Old   August 31, 2013, 15:16
Default
  #8
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
it mean that I have to open another terminal when run is doing in the folder of case and type in it:shutdown +5 ?
then 5 minutes after finishing of the run the PC will be turned off?!
----------------
I knew what you mean! I have to add this to the script that use for the run,right?
if its so,then
Code:
rhoCentralFoam shutdown +5
seems be true without need to use a script,am I correct?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 31, 2013, 15:28
Default
  #9
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,648
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Uhm, no.
I guess you're not inspired to work on this today...

In my previous example, the respective script would be:
Code:
#!/bin/sh
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

runApplication blockMesh
runApplication icoFoam
shutdown +5

#or even
#runApplication shutdown +5
__________________
wyldckat is offline   Reply With Quote

Old   August 31, 2013, 15:54
Default
  #10
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
Bruno I use this:
Code:
#!/bin/bash
solver=$2
pyFoamPlotRunner.py --hardcopy --non-persist --with-deltat --with-courant --report-usage --report-analyzed-data --procnr=$1 $solver
then if I add shutdown +5 to it is it true?
like:
Code:
#!/bin/bash
solver=$2
pyFoamPlotRunner.py --hardcopy --non-persist --with-deltat --with-courant --report-usage --report-analyzed-data --procnr=$1 $solver
shutdown +5
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   September 2, 2013, 02:46
Default
  #11
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
hi Bruno
It didn't turn off,i tested in two times.it goes to a state like hibernate in windows but remains ON.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   September 3, 2013, 16:05
Default
  #12
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,648
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Ehsan,

I'll quote myself:
Quote:
Originally Posted by wyldckat View Post
  1. Read the instructions for using shutdown.
    Code:
    man shutdown
    If you do not read+study the instructions carefully, don't expect me to help you recover lost work
Apparently you did not study the instructions, because if you did, you would have seen this:
Quote:
Code:
       -h     Requests  that  the system be either halted or powered off after
              it has been brought down, with the choice as to which left up to
              the system.

       -H     Requests  that  the  system  be halted after it has been brought
              down.

       -P     Requests that the system  be  powered  off  after  it  has  been
              brought down.
You'll have to test which option works for your system.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   September 3, 2013, 16:14
Default
  #13
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
Hi Bruno,
then I haven't read that carefully
then this should be correct so that it shut down,right?
Code:
#!/bin/bash
solver=$2
pyFoamPlotRunner.py --hardcopy --non-persist --with-deltat --with-courant --report-usage --report-analyzed-data --procnr=$1 $solver
shutdown +5 -p
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   September 3, 2013, 16:20
Default
  #14
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,648
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
OK, if I have to detail every step, here goes :
  1. Close all programs. If you are running any simulation, wait until it is over, before you follow these instructions.
  2. Close all terminal windows and tabs. Then start a new terminal.
  3. Try the first option "-h":
    Code:
    shutdown -h now
    Wait for it to terminate Ubuntu and power down automatically. If it does not power down as expected, then this option doesn't work. Restart the computer.
  4. Once you're back on Ubuntu, try the next option:
    Code:
    shutdown -H now
    Wait for it to terminate Ubuntu and power down automatically. If it does not power down as expected, then this option doesn't work. Restart the computer.
  5. Once you're back on Ubuntu, try the next option:
    Code:
    shutdown -P now
    Wait for it to terminate Ubuntu and power down automatically. If it does not power down as expected, then this option doesn't work. Restart the computer.
  6. If you have reached this step and your machine won't power down with any one of these commands, then it's because none of them will work.
immortality likes this.
__________________

Last edited by wyldckat; September 3, 2013 at 16:42. Reason: #4 should use the "-H" option
wyldckat is offline   Reply With Quote

Old   September 3, 2013, 16:53
Default
  #15
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
thanks Bruno,
but the last run is working and ends this morning,I have to get up earlier!
then shutdown doesn't mean power off?and "halt" is a state like sleep(or such thing) in windows?whats the benefit of "halt"?!
it surely helps some year later I hope !
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   September 4, 2013, 01:13
Default
  #16
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
Hi dear Bruno
shutdown -h and -P worked and powered off the PC,but -H option didn't(only the page with Ubuntu logo shown),is there any preference in using -h or -P options or isn't?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   September 4, 2013, 16:06
Default
  #17
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,648
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Quote:
Originally Posted by immortality View Post
shutdown -h and -P worked and powered off the PC,but -H option didn't(only the page with Ubuntu logo shown),is there any preference in using -h or -P options or isn't?
Whatever works for you, use it. It's that simple.
immortality likes this.
__________________
wyldckat is offline   Reply With Quote

Old   December 24, 2013, 16:44
Default
  #18
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
automatic shut down the PC after ending of run
dear Bruno,may using shutdown had been causing the problem of lost data?
#11:
Quote:
hi Bruno
It didn't turn off,i tested in two times.it goes to a state like hibernate in windows but remains ON.
I remember this issue,could it be harmful in your opinion?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   December 25, 2013, 10:14
Default
  #19
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,648
Blog Entries: 39
Rep Power: 99
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Ehsan,

Quote:
Originally Posted by wyldckat View Post
  1. Read the instructions for using shutdown.
    Code:
    man shutdown
    If you do not read+study the instructions carefully, don't expect me to help you recover lost work
The last sentence on this quote of mine, right now feels considerably ominous ...

Quote:
Originally Posted by immortality View Post
automatic shut down the PC after ending of run
dear Bruno,may using shutdown had been causing the problem of lost data?
#11:
I remember this issue,could it be harmful in your opinion?
I did a quick search about this yesterday night, after seeing your post. You were using Ubuntu 11.10, which is a somewhat old version of Ubuntu. Nonetheless, it was released in October 2011, so it shouldn't be too old.
In addition, you used the shutdown command, which should be recent enough and should always go through all of the necessary steps for a safe shut-down.

The "-h" and the "-P" options are usually the same thing in some systems, since the "-h" is the generic option for "either halt or power down, whichever the system can handle".
Neither one should use a forceful shut-down.

From my search, I found the following details:
  1. The command halt use to be the an old version of said command (before 2009?), which did indeed do a complete halt to the machine, without stepping through every safe step for a proper shut-down.
    • This should have not occurred in your system, because the default installation of halt and reboot will actually call the command shutdown, with the respective options.
  2. According to this blog post: http://kouroshp.blogspot.pt/2013/02/...inux-dual.html - Windows 8 uses a semi-hibernation mechanism, so that it can boot a lot faster after the first shut-down (@Microsoft: this is called cheating, not performance!). What happened with that blogger was that since Windows 8 can shut down to a semi-hibernation state, it also keeps a snapshot of the folder/file structure of the NTFS partitions. Result: copying anything on Linux to an NTFS partition, will lead to Windows not knowing about it, because it does not re-check the disk for any outside changes. (And that's why cheating is wrong )
    • Of course the big question here is: were you already using Windows 8 at that time?
    • By the way, that blog post explains how to turn off the "Turn-on fast startup (recommended)" feature in Windows 8.
  3. On this thread at the Raspberry Pi forum: http://www.raspberrypi.org/phpBB3/vi...p?f=63&t=34615 - it discusses the situation where a command line shut-down did not let the hard-drives properly save data before shutting down. Quoting from the last post:
    Quote:
    A filesystem is sync-ed as part of being unmounted, so in theory no explicit sync is necessary.

    "halt" traditionally stops a UNIX computer dead in its tracks. However that was so problematic that nowdays on Linux if you type "halt" when the system is running normally then it runs "shutdown -h now" instead. "shutdown" runs the scripts to unmount all disks.

    It does rather sound as if the RPi's driver pulled the power to the SD card too soon. SD cards have wear levelling, and this makes it difficult to know when a large amount of disk I/O is actually completed, and thus when a device driver closing a device can drop the power without causing corruption.

    As a result I'd try to avoid a scenario where you do a large amount of disk I/O as part of shutting the machine down. That is, I'd shut down with "sync && sleep 10 && shutdown -h now".
    • This is where I learned about the old halt behaviour.
    • The necessity to call sync and wait 10 seconds was only necessary in this situation because the SD didn't give enough feedback sooner or was powered down too soon.
    • Either way, although you didn't call sync before shutdown, should not have affected the stability of your files, since you always gave a 5 minute delay before the actual shutdown occurred. This should have given more than enough time to finish saving the files on memory to the disk on its own and then safely shutting down.

Therefore, the big remaining questions, based on this, are:
  1. Were you already using at that time Windows 8 (or 7 or Vista)? Or perhaps you hibernated Windows XP before going to Ubuntu?
  2. From where exactly did the files disappear from? Linux or Windows? Or both?
  3. Perhaps you had installed something in Ubuntu that damaged the conventional shutdown application and scripts?
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   December 25, 2013, 16:39
Default
  #20
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
Hi dear Bruno,
thanks for nice information and searching,
1-at that time I had a Windows 7 on a partition.
2-I was in Ubuntu and face to lack of space,then moved all files to a NTFS partition, some minutes later I wanted to go to that partition,but it took a long time think of 3-4 minutes and the partition didn't open,then I restarted the PC and when it turned on I saw that that partition doesn't open and instead shows an error message that was saying something about the partition is unmounted(I saw it in Windows and all things was deleted,even in Windows it was showing a message that this partition is corrupted,... I clearly remember),... I remember this was the starting of trouble,then I brought the internal hard(I hadn't any external hard at that time) to the shop and after some days go and come lastly I returned it back to home happily that noticed the partition that was after it has been deleted like previous and after that it was the linux turn,...and other things that you know.
3-now I don't think it was because of shutdown command,because this was aroubd one week or ten days that whenever I wanted to open a huge folder on NTFS partitions(they were data partitions,not XP or 7 partitions) it seemed the PC was becoming locked,even mouse didn't move and this was taking around 1 minute and suddenly it was waking up from a sleep and was continuing to work.
at those days I had very stress and wanted to resolve the problem and didn't track the probable causes.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Case running in serial, but Parallel run gives error atmcfd OpenFOAM Running, Solving & CFD 18 March 26, 2016 13:40
RPM in Wind Turbine Pankaj CFX 9 November 23, 2009 05:05
What's the best order to run this simulation in? siw CFX 1 November 4, 2009 20:42
serial run fine, but parallel run diverged phsieh2005 OpenFOAM Running, Solving & CFD 2 October 6, 2009 08:33
No results for solid domain Gary Holland CFX 10 March 13, 2009 04:30


All times are GMT -4. The time now is 21:03.