2014年8月29日 星期五

[Shell Script] How to take the content of a text file as the parameter of a shell script call

If you have record the pid of a application in a file named PID.pid, and you want to check if the process of the application still alive. You can try the following:
#!/bin/bash

if ps -p "$(< PID.pid)" > /dev/null 2>&1
then
     echo "Process is running......" >&2
     exit 1
else
    echo "Process is not running......" >&2
     exit 0
fi




Evernote helps you remember everything and get organized effortlessly. Download Evernote.

沒有留言:

張貼留言