Script with lsof works well on shell not on cron Script with lsof works well on shell not on cron shell shell

Script with lsof works well on shell not on cron


from your working cmd-line, do

which lsofwhich grepwhich wcwhich date

Take the full paths for each of these commands and add them into your shell script, producing something like

/bin/echo "Timestamp: `/bin/date +"%m-%d-%y %T"` Files: `/usr/sbin/lsof | /bin/grep app | /bin/wc -l`"

OR you can set a PATH var to include the missing values in your script, i.e.

 PATH=/usr/sbin:${PATH}

Also unless you expect your script to be run from a true Bourne Shell environment, join the early 90's and use the form $( cmd ... ) for cmd-substitution, rather than backticks. The Ksh 93 book, published in 1995 remarks that backticks for command substitution are deprecated ;-)

IHTH