mergecap fails to create output file when run from crontab

1

I have created a script to merge pcap files using 'mergecap -w '. The script doesn't work as the output file is not already present. So I tried to use 'touch outputfile.pcap' before the mergecap command. But that doesn't create an empty pcap file. All it creates is a temporary file with gibberish on its filename. How will I solve this issue??

Jishnu U Nair

Posted 2014-02-06T09:45:37.420

Reputation: 263

If something works from a terminal but doesn't work through cron, the issue is almost always a difference in environment. Is the working directory, path, user security context etc. what you expect? You can make a short script that does things like whoami/id, pwd, echo $PATH and so on to test it. – a CVn – 2014-02-06T09:49:03.063

I tried that, and simple script seems to work, its just this script thats not running. The "mergecap -w "Merge_${TAG1}".pcap ${FILES[@]}" command fails to run on crontab and syslog says a mail is sent – Jishnu U Nair – 2014-02-06T10:29:43.827

Well, I'd expect neither $TAG1 nor $FILES to be populated within crontab, and $PATH might be different when running through cron. – a CVn – 2014-02-06T10:37:37.753

No answers