In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.