I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution.
Update (2020-03-29) When I originally wrote this blog post, my intent was to describe how things worked on a typical system at the time. Unfortunately, the operation of bash startup scripts is dependent on patches added by OS distributions, compile-time options and if bash thinks it was invoked by sshd or rshd. I have no desire to add complexity to this post, so instead please read this as a rough
ããã«ã¡ã¯ããµããã³USP MAGAZINEç·¨éé·ã®ã¾ã¤ããã§ããæ¨æ¥ã¯é¢¨ãç¸è£ãã¦ã¾ãããã©ãçå¼¾ä½æ°å§ã£ã¦å¼ã¶ãã§ããããã¥ã¼ã¹ã®é¡åãè¦ãã¨ããããã§ãèµ·ãã£ãã!?ãã¨ã³ã£ãããã¾ããã ãã®1ããã®2ã«ç¶ããOSC 2012 Tokyo/Springã§ã®ã»ãã·ã§ã³ã®ç¶ãã¨ããã¤ããã ã£ãã®ã§ãããæ¸ãã¦ãããã¡ã«ã ãã¶ãã®ä¸ã§èªããã¦ãããã¿ããé¸è±ãã¦ãã¾ã£ãã®ã§ãããã¼ã«è¡ãã¾ããã§ãããã®2ã§èªããªãã£ãJOINã®è©±ã§ãã INNER JOINãUNIXã³ãã³ãã§ã§ããã®ç¥ããªã¤ã«? INNER JOIN(å é¨çµå)ã¨ããã°ãSQLãããã£ããããã°å¿ ãç»å ´ããæ¦å¿µããã®INNER JOINãããã³ãã³ããå¤ãããUNIXã«åå¨ãã(POSIXæ¨æºã§ãã)ã®ãç¥ã£ã¦ãã¾ãã? âãç¥ããªãã ããããUNIXç³»OSã®ã¿ã¼ããã«ç¨æãã¦è©¦ãã¦ã¿ã¾ãããã ã¾ãã¯ãä¼å¡çªå·ã¨ã
SSH ãã°ã¤ã³ãããªãã¢ã«ã¦ã³ããä½ã - Ceekz Logs ï¼åç°å ç·ï¼ çæ³¢ã®æ¥è¨ï¼ ãªãã»ã©ã¼ã ãã£ã¦ã¿ãã /bin/false # /usr/sbin/usermod -s /bin/false hoge su hoge ãã¦ãã¹ã¯ã¼ãå ¥ãã¦ãä½ãããããªãã£ãã å¥ãµã¼ããã ssh [email protected] ãããä¸ã®ããã«è¨ãããã Last login: Mon May 26 17:00:04 2008 from xxx.xxx.xxx.xxx Connection to foo.com closed. /sbin/nologin # /usr/sbin/usermod -s /sbin/nologin hoge su hoge ãã¦ãã¹ã¯ã¼ãå ¥ãããä¸ã®ããã«è¨ãããã This account is currently not available. å¥ãµã¼ããã
ãã·ã§ã«ã¹ã¯ãªããã®å®è¡éç¨ã§ã¨ã©ã¼ãçºçããå ´åã«å¦çãæ¢ããããã»ã»ã»ããããããã·ã³ãã«(ç°¡å)ã«å®ç¾ãããå ´åã«ä½¿ãã¾ãã ä¾ãã°ã以ä¸ã®ãããªã·ã§ã«ã¹ã¯ãªãããæ¸ããå ´åããã #!/bin/sh mkdir /tmp/hoge/fuga touch /tmp/hoge/fuga/test.txt å®è¡çµæã¯ä»¥ä¸ã®ããã«ãªãã¾ãã $ ./test.sh mkdir: ãã£ã¬ã¯ã㪠`/tmp/hoge/fuga' ãä½æã§ãã¾ãã: ãã®ãããªãã¡ã¤ã«ããã£ã¬ã¯ããªã¯ããã¾ãã touch: `/tmp/hoge/fuga/test.txt'ã«touchã§ãã¾ããã§ãã: ãã®ãããªãã¡ã¤ã«ããã£ã¬ã¯ããªã¯ããã¾ãã/tmp/hogeãã£ã¬ã¯ããªãåå¨ããªãã®ã§ã/tmp/hoge/fugaã®mkdirã§ããã¾ããã¾ãæ®éã§ãããããã ããä½ãèããã«æ¸ãã¨ãâã®ããã«ããã®
ã³ã¼ããã±ãããããã§ãããã³ã¼ããã±ããã¨ã¯ã¡ãã£ã¨éãç¨éãããªãã¨ã¯æãã¾ãããåã®ããæ¹ãæ¸ãã¦ã¿ãã åããããæ°è¡ã¦ãã©ã®æ¸ãæ¨ã¦ããã°ã©ã ãæ¸ãã¾ããä½ãæ°ããã¢ã¸ã¥ã¼ã«ã試ãããã¨ãã¨ãã SYNOPSIS ãã³ãããã¦åããã¦ã¿ãã®ã§ä¸ã¤ãã¡ãã£ã¨æ¸ãæãã¦ã¿ã¦ããä¸ã¤ãã¢ããªã±ã¼ã·ã§ã³ã®ä¸ã§ãããªé¢¨ã«ä½¿ããã¨ãããªã¼ã¨ããã¤ã¡ã¼ã¸ã«ãã£ã¦ããã«ããä¸ã¤ãã¨ãã ããã§å°ãã®ã¯ãåã®ãã¼ãã³ã°ã»ã³ã¹ï¼ããããã£ãã©ãªã¼ãï¼ï¼ã貧ãããããªã®ãã a.pl ã¨ã hoge.pl ã¨ã re.pl ã¨ã lwp.pl ã¨ããããã«ããããµããååã§æ¸ãå§ãã¦ãã¾ããæ¸ãæ¨ã¦ããã°ã©ã ã®ãã¡ã¤ã«åãªãã¦ãã¡ãã¡èãã¦ãããªãããããã¢ãããªååãæãã¤ãéã«æ¸ãçµãã£ã¦ãã¾ããããçããã®ã ãããã¨ãã£ã¦ã¯ã³ã©ã¤ãã¼ã¨ã perlsh ã¿ãããªã®ã¯æ¬å½ã«ä¸åæ¸ãããããã£ããã
Blogging is a disease: selfkleptomania, your normal condition. About GPG Public Key ååãphpDocumentorã®ã½ã¼ã¹ã«å¤ãªãã¨ãæ¸ãã¦ããã¨ããã®ã§è¦ãã¨ã確ãã«å¤ã ãé·ãã³ã¡ã³ãé¨åãé¤ãã¨ãããªã£ã¦ããã #!/bin/sh if [ -z "$PHP" ]; then PHP=`which php` fi (exec $PHP -C -q -d output_buffering=1 "$0" "$@") 2>/dev/null if [ "$?" -ne "0" ]; then echo "FAILED: Bad environment variable \$PHP (set to \"$PHP\")" exit 1 fi exit 0 <?php ob_end_clean(); // mak
ãªã¢ã¼ããã·ã³ã¸ã®ãã°ã¤ã³ããã¡ã¤ã«ã®ã³ãã¼ãªã©ãã·ã¹ãã 管çä½æ¥å ¨è¬ã§SSHãå©ç¨ããæ©ä¼ã¯å¤ããSSHã§ã®ä½æ¥ãå¹çããé²ããã«ã¯ãè¤æ°ã®ãªã¢ã¼ããã·ã³ã«å¯¾ãã¦ã³ãã³ããåæã«å®è¡ã§ãããã¼ã«ã使ã£ã¦ã¿ãã¨ããã ããããã®è¨äºã§ã¯ãParallel sshãCluster SSHãClusterItã¨ãã3ã¤ã®ãã¼ã«ãç´¹ä»ããããããããåä¸ã®ã¿ã¼ããã«ã¦ã£ã³ãã¦ã§å ¥åããã³ãã³ããã対象ã¨ãªãè¤æ°ã®ãªã¢ã¼ããã·ã³ã«å¯¾ãã¦ä¸æã«éããã¨ãã§ããã ãããããã¼ã«ã使ããã«ãopenSSHã§è¤æ°ãã¹ãã«å¯¾ããå¦çãè¡ããã¨ãä¸å¯è½ã§ã¯ãªãããã¨ãã°ãå®è¡ããã³ãã³ããè¨è¿°ãããã¡ã¤ã«ãä½æããbashã®forã«ã¼ãã使ã£ã¦ãè¤æ°ã®ãªã¢ã¼ããã¹ãã«å¯¾ãã¦é 次å®è¡ãã¦ããã°ãããã ãããã¼ã«ã使ããã¨ã«ã¯ã¡ãªãããããããã®1ã¤ã¯ãè¤æ°ã®ãã¹ãã§ä¸¦è¡ãã¦ã³ãã³ããå®è¡ã§ããç¹ã ãçæéã§å®äº
bashã®ãProcess Substitutionãã¨ããæ©è½ã§ãã³ãã³ãã®å®è¡çµæãååã¤ããã¤ãããèªãã¾ãã(thx ãã¤ã¿ãã) $ cat -n <(date; echo foo) 1 Wed Jan 18 21:38:30 JST 2006 2 fooããã使ã£ã¦ããªã¢ã¼ããã¹ãã®ãã¡ã¤ã«ã¨diffãåãã·ã§ã«é¢æ°ãä½ã£ã¦ã¿ã¾ããã ãããªæãã§ä½¿ãã¾ãã $ rdiff -u ~/s.txt REMOTE_HOST:~/d.txtã¾ã-Rãªãã·ã§ã³ã§ãrsyncã®-R, --relativeãªãã·ã§ã³ã®æ§ã«ãã¼ã«ã«ãã¹ãã®ãã¹ããªã¢ã¼ããã¹ãã®ç¸å¯¾ãã¹ã¨ãã¦æå®ã§ãã¾ãããã¨ãã°ããã¼ã«ã«ãã¹ãã®/very/very/long/path/t.txtã¨ãªã¢ã¼ããã¹ãã®åããã¹ã®ãã¡ã¤ã«ãdiffãã¨ãã«ã¯æ¬¡ã®ããã«ãã¦ãªã¢ã¼ããã¹ãå´ã®ãã¹æå®ãç¥è¨ãããã¨ãã§ãã¾ãã $
id:otsuneããã«æãã¦è²°ã£ãapplyãç±ãã BSDç³»ã®OSç¨ã½ãã®ã§ããµã¼ãä¸(Linuxç³»)ãã使ããªãã£ãã§ãã Macã®OSXã ã¨ããã¾ããã shã«æµãè¾¼ã¾ãã«è²ã ã³ãã³ããå®è¡ã§ãããã§ããã ls ã®çµæãxargsã§æ¸¡ãã¦ãããã¨applyã§ããããªãã¨ãã§ããï¼ ls | xargs apply "du -s" ã¨ãã㨠16 README 8 Rakefile 56 app 0 components 56 config 8 db 8 doc 0 lib 0 log 440 public 104 script 32 test 0 tmp 0 vendorã¨ãã§ããã£ã¬ã¯ããªã®ä¸è¦§ã¨ãã®åè¨å®¹éãåºãã¾ãããã -dã渡ãã¦ãããã¨å®è¡å 容ãåºããããªã®ã§ ls | xargs apply -d "du -s" ã§è¦ã¦ã¿ã㨠exec du -s README e
å Vine SPARCéçºè ã2003年度æªè¸ã¦ã¼ã¹æ¡æè ãã¦ãã¦æ ªå¼ä¼ç¤¾ç«ã¡ä¸ãæã«åç»ãã¦4å¹´éCTOã¨ãã¦å¾äºãéè·ãã¦ç¾å¨P&Aã©ãã«ã¦å®¢å¡èµ·æ¥å®¶ã¨ãã¦èµ·æ¥æºåä¸ã PHPã«ã³ãã¡ã¬ã³ã¹2007ã®ã©ã¤ããã³ã°ãã¼ã¯ã§PHPã§ã·ã§ã«ãä½ãã¨ãããé¡ã§çºè¡¨ãã¾ãã æãã£ããã¦ã±çãã§çºè¡¨ããã®ã§ãããæãã®ã»ã好è©ãªããã§ããã£ãã§ãã ãã¬ã¼ã³ã®è³æã¯å ¬éãã¦ããã¾ããããã£ã±ããã¢ã§ã¿ããªãã¨ããã¾ãã¤ã³ãã¯ãããªãã§ããã ãã¢ã§ã¯ãå®éã«ä½¿ã£ãããphsh ããã°ã¤ã³ã·ã§ã«ã«ãã¦ã¿ãããã¾ããw ã½ã¼ã¹ã³ã¼ãã¯å人çãªå ¬éãªãã¸ããªã§ç®¡çãã¦ã¾ãã®ã§ããã¦ã³ãã¼ããã¦ä½¿ã£ã¦ã¿ã¦ãã ããã ç ®ããªãç¼ããªãããã£ã¦ãã£ã¦ãã ãããªã phsh è¦ PEAR::Console_Getopt, readline, pcntl ã§ã å¿«é©ãªã·ã§ã«ã©ã¤ãã!!
åãã³ãã³ããè¤æ°ã®ãµã¼ãã§å®è¡ YAPC::Asia 2007ã§LTãã¦ãã¾ãã sshã§ï¼ã¤ã®ã³ãã³ããè¤æ°ã®ãµã¼ãã«é çªã«å®è¡ããã¦ããã¾ãã ããtentakel > tentakel -g myservers uptime ### ntp02.example.org(stat: 0, dur(s): 0.81): 9:53PM up 161 days, 21:01, 0 users, load averages: 0.00, 0.02, 0.00 ### cvs02.example.org(stat: 0, dur(s): 0.9): 9:53PM up 43 days, 18:59, 0 users, load averages: 0.00, 0.01, 0.00 ### nagios.example.org(stat: 0, dur(s): 0.92): 9:53PM up
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}