You are not logged in.
Pages: 1
when I create a file in /etc/cron.d/:
05 19 * * * wjzhou echo "OK?" >/tmp/cron-is-ok
When time is due, a file 'cron-is-ok' created, but owner is 'root', not 'wjzhou',
it seems this job does not run as user 'wjzhou', then I check /var/log/crond.log:
Oct 11 19:05:01 localhost crond[10480]: FILE /etc/cron.d/test USER root PID 10487 wjzhou echo "OK?" >/tmp/cron-is-ok
Oct 11 19:05:01 localhost crond[10480]: exit status 127 from user root wjzhou echo "OK?" >/tmp/cron-is-ok
Oct 11 19:05:01 localhost crond[10489]: mailing cron output for user root wjzhou echo "OK?" >/tmp/cron-is-ok
How to run a cron job as a specific user use dir /etc/cron.d?
Last edited by flytwokites (2010-10-12 13:46:55)
Offline
Run
crontab -l
when logged as wjzhou.
[karol@black ~]$ crontab -l
no crontab for karol
man crontab
for details.
Last edited by karol (2010-10-11 11:39:36)
Offline
I check the book 'Linux Administration HandBook':
http://books.google.com/books?id=GB_O89 … 22&f=false
minute hour day month weekday [username] command
The format of job in /etc/cron.d is different to per user job, it has a 'username' field, but dcron seems ignore
this field.
Is dcron actually not implemented this feature?
Offline
I'm not so sure about the [username] field. I don't see it documented in crontab's manpage even. It may be an archaic way of doing it, as the current way is for each user to have their own crontab.
Offline
Why not create cron job with
$ crontab -e
instead create file under /etc/cron.d
Ask, and it shall be given you.
Seek, and ye shall find.
Knock, and it shall be opened unto you.
Offline
Why not create cron job with
$ crontab -e
instead create file under /etc/cron.d
Because I want to write a bash script to add a cron job for an user and do not override that user's existing jobs.
Offline
You could use "sudo -u [username]".
Offline
Thinks for your answers.
It is worked with create file under /etc/cron.d and use this format:
45 21 * * * su -c "<command>" -s /bin/bash <username>
Offline
Pages: 1