Crontab O/P
Running the below command in command line gives fine O/P but using it in crontab give wrong O/P
lsof -p 22669 |wc -l crontab entry * * * * * lsof -p 22669 |wc -l >/dev/pts/1 |
what does "O/P" mean?
|
Quote:
|
I'd suggest writing "output" in future...
so what IS the wrong output? what is the correct output? You should always use full paths to binaries, e.g. /usr/sbin/lsof and /bin/wc a PID seems like a real odd thing to put in a cronjob to me though. Every single minute? maybe you would be better off with a watch statement instead of a cron? |
Quote:
* * * * * /usr/local/bin/lsof -p `/usr/bin/ps -aef |/usr/local/bin/grep java |/usr/local/bin/awk '{print $2}'` |/usr/local/bin/wc -l > /dev/pts/3 |
Quote:
I want this output for every 15 minutes, but in crontab I have not mentioned 15 minutes just to verify if it runs * * * * * /usr/local/bin/lsof -p `/usr/bin/ps -aef |/usr/local/bin/grep java |/usr/local/bin/awk '{print $2}'` |/usr/local/bin/wc -l > /dev/pts/3 |
Ouch, that's painful... just run "/usr/bin/pgrep java -n" to get the newest java pid. but then if you want all files opened by the java process, "/usr/local/bin/lsof -c java | wc -l" would give you that I reckon.
what cron are you running this in? If it's on /etc/crontab then you need to add the username to execute it as before the command. |
Chris thank you for providing the short form of the command
I am running the cron locally under my home directory and it works now. Thanks, but any idea what was wrong in my command |
All times are GMT -5. The time now is 02:59 PM. |