Cronjob to search for new files and send the file list via email

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cronjob to search for new files and send the file list via email

    searches for executable files, i.e. for hacking attack detection
    make sure all path are correct, i.e. /root/gumscripts/logs/ exists
    Code:
    #!/bin/sh
    LOGTIME=`date "+%Y-%m-%d %H:%M:%S "`
    LOGFILE=/root/gumscripts/logs/${LOGTIME}new_files.log
    
    latest=$(
    find /home/*/public_html -maxdepth 5 -mtime -1 -type f \( -name "*.py" -or -name "*.php" -or -name "*.sh" -or -name "*.pl" \) -ls
    )
    echo "$latest" > ${LOGFILE}
    [ -n "$latest" ] &&
    #mutt -s "New Files Log" -a "/root/gumscripts/out.txt" username@email.com
    echo "$latest" | mutt -s "New files log $LOGTIME" username@email.com
    Advertise your mobile site for FREE with AdTwirl

Working...
X