This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Created SCRIPT run by CRON, TSHARK will not run from CRON

0

I have created a script to run tshark to get a packet capture periodically during the day on a REDHAT server. If I run the shell script under either "root" or another user id (MANUALLY) it works and writes to the files i've created. But if I let cron run the shell script, everything works except the " tshark -i eth1 -c # -w /tmp/BUILD ". I have tried changing permission on script, created files, binary file,... but nothing seems to allow tshark to run if script is executed via cron.

I also followed link text for TCPDUMP and WIRESHARK and neither have worked...

Any suggestions?? I know it is permissions related somewhere. should I make some kind of "cron" user id or group the owner of the script or tshark binary?

Thanks!!!!

asked 21 Mar '16, 09:44

msmorten's gravatar image

msmorten
4558
accept rate: 0%


One Answer:

1

If the script runs successfully when ran manually from any user, it is not likely to be an issue of rights - a crontab is normally defined for a particular user and executes the commands with privileges of that user. I expect that your problem is that cron does not set the environment variables, including path. Therefore, you have to use absolute paths to the executables in the scripts started by cron. So instead of just tshark, you must use something like /usr/bin/tshark, but better use which tshark to find out what the absolute path really is at your Linux distribution.

answered 21 Mar '16, 14:19

sindy's gravatar image

sindy
6.0k4851
accept rate: 24%

This makes sooo much sense and I will let you know the results once I test this.

Thank you!!!

(21 Mar '16, 15:08) msmorten

Absolutely worked

(29 Mar '16, 11:34) msmorten