LinuxQuestions.org
Visit Jeremy's Blog.
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 09-22-2016, 11:33 AM   #16
jens
Senior Member
 
Registered: May 2004
Location: Belgium
Distribution: Debian, Slackware, Fedora
Posts: 1,436

Rep: Reputation: 275Reputation: 275Reputation: 275

Quote:
Originally Posted by goumba View Post
According to the man page, that's for read errors, the problem being encountered is on writing.
My bad. I wrongly assumed no one would would ever do a shutdown in such a case.
 
Old 09-23-2016, 04:55 AM   #17
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by jens View Post
My bad. I wrongly assumed no one would would ever do a shutdown in such a case.
I find it peculiar as well, but if logging the operation, I guess I see no harm. I'd rather the machine not shut down myself, this way I'd know I had something to investigate.
 
Old 09-23-2016, 08:30 AM   #18
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,784

Original Poster
Rep: Reputation: 49
Maybe I'm missing something, why is everyone so concerned/astonished about why the machine shuts down after it finishes the only active process it's performing, when everything you would see on the screen would be logged to the file you can easily read next time you're on the computer, turned on of course
 
Old 09-23-2016, 09:08 AM   #19
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Nothing particularly wrong with it. I think it's just perhaps that the system is shutting down whether the task completes successfully or not, which means you have to make it a point to look at that log to see if anything went wrong. I guess a lot of us would prefer to know something went wrong, and the system not shutting down as it should have is a strong indicator that such happened.
 
Old 09-23-2016, 10:08 AM   #20
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,784

Original Poster
Rep: Reputation: 49
OK.
I haven't tried it yet, but if we're sending the output to a file will it still show on the screen as well where it had issues?
 
Old 09-23-2016, 10:23 AM   #21
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by rjo98 View Post
OK.
I haven't tried it yet, but if we're sending the output to a file will it still show on the screen as well where it had issues?
If you want to have output saved both to a file and stdout, use tee

Code:
command | tee outputfile

Last edited by goumba; 09-23-2016 at 10:25 AM.
 
1 members found this post helpful.
Old 09-23-2016, 10:24 AM   #22
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,784

Original Poster
Rep: Reputation: 49
for me the log file is fine, was just trying to understand the shutdown concern. thanks.
 
Old 09-23-2016, 01:08 PM   #23
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061
Might want to
Code:
command 2>&1 | tee outfile
The 2>&1 directs the standard output and the standard error channels into one stream.

Hope this helps some.
 
1 members found this post helpful.
Old 09-23-2016, 01:25 PM   #24
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,784

Original Poster
Rep: Reputation: 49
thanks guys
 
Old 09-23-2016, 02:26 PM   #25
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061
Quote:
Originally Posted by rjo98 View Post
for me the log file is fine, was just trying to understand the shutdown concern. thanks.
Assuming you're wiping a second (or third or whatever) disk drive (NOT sda1, that's your system drive), when your wiping process completes, with or without error, you can shut down the system with
Code:
init 0
That will close all running processes, flush the buffers to the system disk (so your log is actually written completely) and shut the system down and turn off the power.

The system does not write to a disk every time something appears on your monitor; it fills a buffer set aside for I/O and when the buffer is full it is written to the device. You may see this when you're writing to a flash drive and the write has not completed until you chose to eject the flash drive -- there is a lot of flashing light and you need to wait for that to complete. On a disk drive it happens so quickly that it's hard to actually see the delay when the buffers are written.

One way of assuring that buffers have been flushed to a device, hard drive, flash drive, whatever is to issue the sync command which flushes the buffers. A typical way to do so is
Code:
sync;sync;sync
You'll probably see a noticeable delay on the first sync and the second and third will be almost instantaneous. It's a little bit of overkill to issue three syncs but you're assured that the buffers have really all been flushed and the whole thing takes only a second or two to complete.

Note that including flush or sync commands within a shell program after every line that prints something is not a good idea; once, at the end of the program, is good enough and then, in your case with wiping the drive, would be done once before shutting the system down.

Hope this helps some.
 
1 members found this post helpful.
Old 09-23-2016, 02:29 PM   #26
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,784

Original Poster
Rep: Reputation: 49
Thanks. Yup, the hard drive in question is not the primary one, just threw it in this machine purely to wipe it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: How To Automatically Shut Down Your Computer After A Download Finishes LXer Syndicated Linux News 0 04-27-2011 06:20 PM
[SOLVED] Shut down Puppy Linux 4.20 from command line or keyboard shortcut without freezing ubume2 Linux - Newbie 2 09-18-2009 01:27 PM
How to enter graphical mode (run level 5) command line (run lenel 3) edmondgyampoh Linux - Newbie 3 05-15-2009 07:33 PM
trying to fix xwindows or just run command line... changing run levels dave247 Debian 2 11-18-2008 07:11 PM
Straightforward way to shut down graphical display on Fedora 7 from command line Sheridan Linux - Newbie 8 02-11-2008 11:20 AM

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

All times are GMT -5. The time now is 10:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration