Find Any Modified Files for the Past 24 Hours

#!/bin/bash

current_status=$(mktemp /tmp/temp-status.XXXXXX)

find ~/public_html/ -mtime -1 -type f -print > ${current_status}

if [[ -s ${current_status} ]] ; then
 
echo "There are some modified files. See the list below:
=======================
"

cat ${current_status}

echo "
=======================

If you have not made any updates or if you
have not installed any new software like plugins and themes,
please check the files"
fi;

rm -f ${current_status}

The following short script will check your files and it would list all files which have been modified in the past 24 hours.

Just copy and paste the code below into a file and then execute the file.

#!/bin/bash

current_status=$(mktemp /tmp/temp-status.XXXXXX)

find ~/public_html/ -mtime -1 -type f -print > ${current_status}

if [[ -s ${current_status} ]] ; then
 
echo "There are some modified files. See the list below:
=======================
"

cat ${current_status}

echo "
=======================

If you have not made any updates or if you
have not installed any new software like plugins and themes,
please check the files"
fi;

rm -f ${current_status}

Note that you would need to change the path if your files are not stored at ~/public_html.

Additionally, you could do is to set up this as a Cron job and email the output over each time there are any modified files.

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. The first line is the shebang line which tells the shell that it should execute this script using Python.
2. The next line creates a temporary file in the current directory and stores the list of files that were modified in the last 24 hours.
3. The third line is

Snippet By Dev Dojo

·

Created June 12th, 2021

·

Report Snippet