Managing Foreground Processes 前台程序的管理 Linux下的大部分命令都是运行在前台,命令通常会开始执行,然后会占用命令行,直到进程运行结束,进程可以允许在运行的过程中和用户进行交互,然后再推出,默认情况下所有的输出都会直接显示在终端 启动一个进程 默认情况下,进程都是前台启动的,除非这个进程退出,或者状态改……
标签目录:shell
以下是与标签 “shell” 相关联的文章LINUX 常用的50个命令及例子11~20
LINUX 常用的50个命令及例子1~10
linux 清理semaphores ruby脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/usr/bin/env oo-ruby # # # require 'etc' def get_ps_users() uids = %x[ps -o user -e].split("\n").grep(/^[1-6]{4}/).uniq! usernames = uids.collect do |uid| Etc.getpwuid(uid.to_i).name end return usernames end def main() kernel_sem = %x[/sbin/sysctl kernel.sem].split[-1] results = %x[ /usr/bin/ipcs -s -c].split("\n")[1..-1] user_semaphores = Hash.new(Array.new) results.each do |result| values = result.split next unless values[2] =~ /[a-z0-9]{24}/ user_semaphores[values[2]] += [values[0]] end users_with_procs = get_ps_users() users_without_procs = user_semaphores.keys - users_with_procs all_semaphores = [] users_without_procs.collect do |user| all_semaphores += user_semaphores[user] end cmd_str = ("-s %s " * all_semaphores.size) % all_semaphores puts %x[/usr/bin/ipcrm #{cmd_str}] puts "Cleaned #{all_semaphores.size} semaphores." end if __FILE__ == $0 main() end |