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

Started on the old forum in October 2020 · view the original in the archive · old links redirect here

No replies · 137 views · started 6 years ago · 1 min read

GumSlone Administrator Principal · 1,690 posts #1

searches for executable files, i.e. for hacking attack detection make sure all path are correct, i.e. /root/gumscripts/logs/ exists

#!/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
👍 2
Share

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close