?
Solved

cleaning up output from mysql command in shell script

Posted on 2014-01-22
3
Medium Priority
?
593 Views
Last Modified: 2014-01-25
Hello

If i had a shell script which ran a mysql command like so

/usr/bin/mysql -u user -ppassword database_name < /path/file.sql

and the sql file contained an update command, what would happen to the 'number of rows affected' output? Where would it go?

I've seen it cleaned up like this before

> /dev/null

What would happen if dev/null was full?

What would happen if the job running the script did not have permission to access /dev/null? Is this possible?

Thank
0
Comment
Question by:andieje
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39801527
The output goes to the "stdout" stream which is by default associated with your terminal.

/dev/null (the null device) is a special file which cannot get full. Everything redirected to it is immediately discarded.

/dev/null is world-writeable.
0
 

Author Comment

by:andieje
ID: 39807226
what if it was running in the background? is that why it is sent to /dev/null
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 39807329
When running a job in the background without output redirection you're at risk to get a ENOTTY error, or at least to see (with longer running jobs) out-of-the-blue text messages arriving at your terminal now and then, so it's good practice to redirect the output, be it stdout or stderr, to a logfile or to the said "special" file /dev/null.
It's not at all mandatory to use /dev/null for background jobs, regular log files will do as well.

A particular case is "nohup". When a process is started in the background prepended with "nohup" and the output is not redirected then "nohup" will capture it on its own and redirect it to a file named "nohup.out".
"nohup" is meant to let your job survive even when its parent shell dies.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question