Created
May 17, 2015 14:46
-
-
Save K-atc/11640416dcf616fa501a to your computer and use it in GitHub Desktop.
特定のタスクをバックグラウンド実行し、好きなタイミングで終了するRubyスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # $ cat ./hoge.sh | |
| # #!/bin/bash | |
| # while true; do | |
| # date; sleep 1 | |
| # done | |
| cmd = "sh ./hoge.sh" | |
| pid = Process.spawn cmd, STDOUT=>STDOUT | |
| puts "current process: #{pid}" | |
| sleep 5 | |
| puts "Kill Process!" | |
| Process.kill 9, pid.to_i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment