Recently help students write a simple script = = (do not spray me ~), the situation frequency, the background operation and the concept of CTRL + Z did not understand clearly made a big joke, the script and the resolution process:
#!/bin/bash while:;d o a= ' date +%y/%m%d%t ' java= ' ps aux |grep vsftpd |awk ' nr==1{print $} ' echo "Time $A,CPU usage $java" >> xiangchen/1.txt sleep Done
At that time directly using CTRL + Z thought is directly in the background to run, later learned to just suspend the foreground task, hang and no background run, hehe--
Later Baidu a bit to find a solution is to put the running task Ctrl + Z suspend suspend:
# SH vsftpd.sh &
# [1] 1159
# jobs-l
# [1]+ 1159 Running./vsftpd.sh &//view running in the background
# $ disown-h%1
# $ PS-EF | grep vsftpd
# root 1492 1143 0 15:42 pts/0 00:00:00/bin/bash./vsftpd.sh
# root 1531 1143 0 15:43 pts/0 00:00:00 grep vsftpd
Here we can let the program end +& hang, and then use the Disown-h% program number to let it run in the background, not affected by the current shell exit. There is also a way to do the same with this effect:
# (./vsftpd.sh &)
# [1]+ killed./vsftpd.sh
# Ps-ef |grep vsftpd
# root 1578 1 0 15:50? 00:00:00/bin/bash./vsftpd.sh
# root 1699 1615 0 15:52 pts/2 00:00:00 grep vsftpd
End script Process: kill-9 process number
[Email protected] ~]# kill-9 1578
[Email protected] ~]# Ps-ef |grep vsftpd
Root 1708 1615 0 15:55 pts/2 00:00:00 grep vsftpd
When the system is running, the script is written to the boot configuration file.
Keep track of what you think about every day.
This article is from the "Linux Nest" blog, please be sure to keep this source http://xiangcc.blog.51cto.com/10201823/1649634
Shell script background Run operation