LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   'lsof' doesn't work in cronjob (http://www.linuxquestions.org/questions/linux-software-2/lsof-doesnt-work-in-cronjob-626479/)

BlackHatRob 03-07-2008 03:09 PM

'lsof' doesn't work in cronjob
 
I have the following example script set up in a cronjob that runs every minute:

#script
#!/bin/bash
lsof > /root/file

#cron entry
* * * * * /root/lsof.sh | tee /root/thisfile

After every minute, the file '/root/thisfile' is created but there is nothing in it. No matter how many different ways I try I cannot get the output of 'lsof' to show up when running in a cronjob.

Tinkster 03-07-2008 03:20 PM

Try specifying the full path to lsof inside your script.



Cheers,
Tink

BlackHatRob 03-07-2008 04:03 PM

Touche'

I figured that as the script was being run by root whose path includes /usr/sbin that it would have run.

Thanks for your help.... It's been a long day.


All times are GMT -5. The time now is 11:17 PM.