Setting up a Cron User

I am attempting to run this command line once/day via a cron to attempt to find all of the recently changed php scripts (as a way to test to make sure a rogue PHP script hasn't been loaded).

find /var/www/vhosts/ -name '*.php' -mtime 0

The script runs from from root, but in my plesk environment it is set up so that root cron jobs DO NOT send out a summary email so as a result I don't get the results sent to me.

I can think of two ways to do this:

1). Add something to the above line so that it sends the output to an email address.

2). Set up a second user in the system that has the right type of privileges to execute this script. I would then change this user to be send summaries.

I need some help with both of these options.  

For #1, can you tell me how I add an email to have the report sent?

For #2, can you tell me how to set up this type of user via Linux Shell script (i.e. direct command lind access).

Thank you.
Paul KonstanskiProject SpecialistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Option #1:

Redirect the output to a file, send the file via email:

find /var/www/vhosts/ -name '*.php' -mtime 0 > output.txt
mail -s "Script Output" < output.txt
Option #2:

This option is a little more complicated, only because we do not know your system.  You should have a user account already (how do you log in?)

If that is the case, simply add the job to your cronjobs using crontab -e.

If you need to add a user, you can use:
useradd <username>

Then set the password:
passwd <username>

I would then lock the account, so nobody can log in as the new user, kind of like a service account.  The user will still be able to run a cron job
passwd -l <username>

Whatever user you use, they will need to have at least read rights to the files and directories in question.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Paul KonstanskiProject SpecialistAuthor Commented:
Excellent answers. One more question.

I don't live in the linux world everyday... so things are a little rusty.

So how would I set up this new user to have "at least read rights" for example to

you can use

chmod +r /var/www/vhosts/

this will give read perm to the dir /var/www/vhosts/

but if you want to give read perm to file in /var/www/vhosts/

then use

chmod +r /var/www/vhosts/*
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.