In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Please explain the meaning of the whole line of code that begins with if in the following Shell script. Have you seen its application scenario?
If (kill-0$ pid 2 > / dev/du11) then echo "oldboy" else echo "oldgirl" fi
Interview question: please explain the meaning of if (kill-0$ pid 2 > / dev/null) code?
If (kill-0$ pid 2 > / dev/null) then echo "oldboy" else echo "oldgirl" fi
The old boy answered the main points:
The-0 in kill-0$ pid means that no signal is sent to the process corresponding to PID, but the existence of the process corresponding to the variable value PID is still checked. If the process corresponding to $pid exists, 0 is returned, and there is no return 1.
2 > / dev/null does not output error messages.
The application scenario in the system is the script code snippet that stops the MySQL service in the / etc/init.d/mysqld script of MySQL.
The program code to shut down the database using the / etc/init.d/mysqld stop command to execute the script is as follows:
'stop')
# Stop daemon. We usea signal here to avoid having to know the
# root password.
Iftest-s "$mysqld_pid_file_path"
Then
Mysqld_pid= `cat "$mysqld_pid_file_path" `
If (kill-0 $mysqld_pid2 > / dev/null)
Then
Echo$echo_n "Shutting down MySQL"
Kill$mysqld_pid
# mysqld shouldremove the pid file when it exits, so wait for it.
Wait_for_pid removed "$mysqld_pid"$mysqld_pid_file_path"; return_value=$?
Else
Log_failure_msg "MySQL server process # $mysqld_pidis not running!"
Rm "$mysqld_pid_file_path"
Fi
# Delete lock forRedHat / SuSE
If test-f "$lock_file_path"
Then
Rm-f "$lock_file_path"
Fi
Exit$return_value
Else
Log_failure_msg "MySQLserver PID file could not be found!"
Fi
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.