Add user in Cron tab
Hy guys ,
I have a big difficult for add user in cron tab and execute a script with this user. ( any user) Then , someone can help me? How proceed I can solve this? Thank in Advanced. |
"crontab -e" if logged in as a given user will create/edit the crontab for that user. It is a vi session and you can add your entries there.
If you're the root user you can use above to modify root's crontab or "crontab -e -u <user>" to specify the user crontab you want to create/edit. You can type "man 5 crontab" to find out the format of records to create. Remember any script you run in crontab will need to be self contained with correct environment variables (especially PATH) as cron jobs do NOT login as the user but rather in a minimal environment. Most of the environment for users is created by logins and it won't be there in a cron job unless included in the script. |
Quote:
Then , I try for this steps ( just test). 1 - crontab -e -u orasid 2 - 24 16 * * * orasid mkdir /home/teste And, this folder or file not criated in /home. |
Two things:
1) What is "orasid" doing in the command "orasid mkdir /home/teste"? Is that a program? What does it do? 2) Did you wait until 16:24 ? |
Thats how you specify the username you want the command to run under. 'orasid' is an oracle os username iirc.
|
But he did "crontab -u orasid", so he's already editing orasid's crontab. I just tried putting my own username in my own crontab, and it threw an error:
Code:
$ crontab -l Code:
$ mail |
A few things to note
http://serverfault.com/questions/352...-specific-user https://www.freebsd.org/doc/handbook...ning-cron.html http://insanelabs.com/linux/linux-cr...ystem-reboots/ |
Quote:
Orasid is a user for oracle in system and yes. I wait for 16:30 , and nothing. |
As i mentioned,.. if you are editing the user crontab,. which you are,. there is no 'username' field. So remove 'orasid' from the crontab, like this:
Code:
crontab -e -u orasid |
Quote:
|
Add user in Cron tab [RESOLVED]
Quote:
Thank you guys. I could create a script that works. Steps 1 - Log for root , before log in user ( su - <user>) . 2 - Before that , create a crontab " crontab -e " . ( Logged in your user, not root) 3 - Create a script " 46 13 * * * touch /home/teste " ( minute hour mday month wday command ) , don't set user again. OBS: Check the PERMINSSION in the folder. |
All times are GMT -5. The time now is 09:34 PM. |