[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Setting up a Cron User

Posted on 2014-08-04
4
Medium Priority
?
440 Views
Last Modified: 2014-08-04
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/crucore.org/essentials24.net/ -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.
0
Comment
Question by:Paul Konstanski
  • 2
4 Comments
 
LVL 23

Expert Comment

by:savone
ID: 40239507
Option #1:

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

find /var/www/vhosts/crucore.org/essentials24.net/ -name '*.php' -mtime 0 > output.txt
mail -s "Script Output" me@mydomain.com < output.txt
0
 
LVL 23

Accepted Solution

by:
savone earned 720 total points
ID: 40239512
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.
0
 

Author Comment

by:Paul Konstanski
ID: 40239559
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

/var/www/vhosts/crucore.org/essentials24.net/
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 200 total points
ID: 40239764
you can use

chmod +r /var/www/vhosts/crucore.org/essentials24.net

this will give read perm to the dir /var/www/vhosts/crucore.org/essentials24.net

but if you want to give read perm to file in /var/www/vhosts/crucore.org/essentials24.net

then use

chmod +r /var/www/vhosts/crucore.org/essentials24.net/*
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This installment of Make It Better gives Media Temple customers the latest news, plugins, and tutorials to make their Grid shared hosting experience that much smoother.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question