Solved cron execute script, but no result

I created jobs according to PF FAQ , logs show that script is execute by cron, but I can not see result
 
Not exactly much to go on is it.
If you want help it would be useful to show what's in your crontab, and what the scripts are.

As a stab in the dark, I'd suggest making sure that any references to executables in your scripts have the full path specified. If the scripts are trying to run programs that are installed somewhere like /usr/local/bin or /usr/local/sbin, and are not specifying the full path, then it won't work.
 
crontab -l
Code:
0-59/5 * * * * root /bin/sh /etc/pflogrotate

nano /etc/pflogrotate
Code:
#!/bin/sh
PFLOG=/var/log/pf.log
FILE=/var/log/pflog5min.$(date "+%Y%m%d%H%M")
pkill -ALRM -u root -U root -t - -x pflogd
if [ -r $PFLOG ] && [ $(stat -f %z $PFLOG) -gt 24 ]; then
  mv $PFLOG $FILE
  pkill -HUP -u root -U root -t - -x pflogd
  tcpdump -n -e -s 160 -ttt -r $FILE | logger -t pf -p local0.info
  rm $FILE
fi
That is my script
 
Remove the 'root' from the crontab line. It's root's crontab so there's no need to specify a user.
 
I removed root from script. No result
Can anybody give me exact example

You have your answer here:

I'd suggest making sure that any references to executables in your scripts have the full path specified. If the scripts are trying to run programs that are installed somewhere like /usr/local/bin or /usr/local/sbin, and are not specifying the full path, then it won't work.
 
PATH is set to /bin:/usr/bin in a user's crontab (see crontab(5)), so gkontos has a point. tcpdump is in /usr/sbin for example.

Try adding this at the top of root's crontab:
Code:
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
 
I gave the example above, I wrote the full path.
Code:
0-59/5 * * * *  /etc/pflogrotate
Code:
#!/bin/sh
PFLOG=/var/log/pf.log
FILE=/var/log/pflog5min.$(date "+%Y%m%d%H%M")
pkill -ALRM -u root -U root -t - -x pflogd
if [ -r $PFLOG ] && [ $(stat -f %z $PFLOG) -gt 24 ]; then
mv $PFLOG $FILE
pkill -HUP -u root -U root -t - -x pflogd
tcpdump -n -e -s 160 -ttt -r $FILE | logger -t pf -p local0.info
rm $FILE
fi
 
Code:
#!/bin/sh
PFLOG=/var/log/pf.log
FILE=/var/log/pflog5min.$(date "+%Y%m%d%H%M")
pkill -ALRM -u root -U root -t - -x pflogd
if [ -r $PFLOG ] && [ $(/usr/bin/stat -f %z $PFLOG) -gt 24 ]; then
  mv $PFLOG $FILE
  #touch $PFLOG
  /bin/pkill -HUP -u root -U root -t - -x pflogd
  /usr/sbin/tcpdump -n -e -s 160 -ttt -r $FILE | /usr/bin/logger -t pf -p local0.info
  rm $FILE
fi
echo "cron has executed my script" >> /tmp/crontest

Wooww, at last worked
 
Back
Top