0

I have two scripts: /home/apps/backup.sh // Just invokes tcpdump.sh /home/apps/tcpdump.sh // Generate a tcpdump file

backup.sh is scheduled by crontab dialy.

backup.sh

#!/bin/sh
/home/apps/tcpdump.sh &

tcpdump.sh

#!/bin/sh
pkill tcpdump
NOWtcpDump=$(date +"%Y%m%d_%H%M%S")
tcpdump -w /var/log/tcpdump/tcpdump.$NOWtcpDump -nn -i ens40 '(dst port 8080)'

crontab -e

0 2 * * *       /home/apps/backup.sh

If I execute /home/apps/backup.sh, manually and it works. Even though, /home/apps/backup.sh is not working well through crontab. I mean, the backup generation is working fine but tcpdump file creation isn't. For some reason, the process of tcpdump.sh get lost.

What is it missing in order to make it works through crontab?

user3637971
  • 155
  • 2
  • 11

0 Answers0