/etc/crontab vs /etc/cron.d vs /var/spool/cron/crontabs/
Hi
I am trying to understand the difference between 3 crontab locations : - /etc/crontab - /etc/cron.d - /var/spool/cron/crontabs/ Which location is used by sys admins ? thx for help. |
Hello,
Have a look at the man page for cron: Code:
man cron Kind regards, Eric |
I already did but need sth kind of 'good practice'.
- /etc/cron.d ---> used by packages - /etc/crontab ---> system crontab (with additional user directive) - /var/spool/cron/crontabs ---> user crontab Code:
REQUIREMENT : Code:
QUESTIONS : |
Hello,
Don't manually create crontab files inside /var/spool/cron/crontabs. They get created using the crontab command, either when logged in as the user (server_user) or as root using the -u option. It's not advised according to the man page. Also for the other two options, read this quote from the man page. Quote:
Kind regards, Eric |
|
I have placed my script in /etc/crontab and everything worked fine but when I placed the same script in /etc/cron.d, script stopped working.
What might be wrong ? |
Hi,
At first hand I'd say that if it works from /etc/crontab and not when placing the file in /etc/cron.d/ that it either has to do with permissions not set correctly or, which is most likely, that your script needs environment variables (which as documented in the quote from the man page) are not loaded when placing it in /etc/cron.d. Kind regards, Eric |
This is file from /etc/cron.d location :
Code:
Why ? |
i thought /var/spool/ is for pending actions so ..
|
Quote:
As mentioned before, scripts that are in /etc/cron.d/ don't load environment variables. I'd look into that part. I'm assuming you added your command as root in the /etc/crontab file. If that's the fact then executing the crontab line will load the user's environment variables which don't get loaded when you put the script in /etc/cron.d. Log in as the user and run: Code:
env Kind regards, Eric |
All times are GMT -5. The time now is 11:26 PM. |