XK8ER
asked on
run crond a user
hello there,
I would like to know how can I run an script every 5 minutes as user apache..
I would like to know how can I run an script every 5 minutes as user apache..
ASKER
any other way to do this rather than to login as apache?
Another possibility is using root's crontab.
Log in as root, issue crontab -e and add
*/5 * * * * su - apache -c "/path/to/script >/path/to/logfile 2>/path/to/errorlog"
On some systems you can also place a file into the /etc/cron.d directory, containing a line in the format
*/5 * * * * apache /path/to/script >/path/to/logfile 2>/path/to/errorlog
Log in as root, issue crontab -e and add
*/5 * * * * su - apache -c "/path/to/script >/path/to/logfile 2>/path/to/errorlog"
On some systems you can also place a file into the /etc/cron.d directory, containing a line in the format
*/5 * * * * apache /path/to/script >/path/to/logfile 2>/path/to/errorlog
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's good practice to never touch /etc/crontab.
Better use the /etc/cron.d directory!
Better use the /etc/cron.d directory!
crontab -e
The user's crontab will be opened by (probably) vi.
Add this line:
*/5 * * * * /path/to/script >/path/to/logfile 2>/path/to/errorlog
Save the file and you're done.
wmp