where does crontab file stored

I use crontab - e to make some change in the file with root and I can display it back with crontab -l.

When I check the file /etc/crontab, I can't find the command. Where does it store ? Will the job be run at specific time ?

Tks
AXISHKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

savoneCommented:
It is stored in /var/spool/cron/username

Change username to the user you are using.  For example, if you do crontab -e as root the file will be stored in /var/spool/cron/root
AXISHKAuthor Commented:
There is another /etc/crontab. Should the schedule job be put under here. Is there any difference ?

Tks again.
Gerwin Jansen, EE MVETopic Advisor Commented:
grep for the command in /var/spool/cron/* to find it
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

omarfaridCommented:
Are you root user? Any particular reason to put it in /etc/crontab?

Only root can edit /etc/crontab file
AXISHKAuthor Commented:
Yes, I'm the root user.

Just wonder where should I put my schedule job. Is there any difference ?

Tks
Gerwin Jansen, EE MVETopic Advisor Commented:
Of course there is difference, cronjob entries of root run with highest privileges. You need to decide whether that is necessary or not. If not run it as a normal user.
AXISHKAuthor Commented:
so, any difference between these two files if both are created by root?

tks
omarfaridCommented:
There should not be a significant difference. I have read that /etc/crontab will read env. variables while the other will not read, but you can set required env. variables in script, etc.
savoneCommented:
There is no difference at all.  /etc/crontab file is a system wide crontab and crontab -e or /var/spool/cron/username is user specific crontab file.
serialbandCommented:
/etc/cron.d ---> used by packages
/etc/crontab ---> system crontab (with additional user directive)
/var/spool/cron/crontab ---> user crontabs

To be clear, there's an extra field in /etc/crontab to set the user it runs as.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AXISHKAuthor Commented:
Tks, last question

For daily housekeeping job and backup tasks, where should I configure it ? Tks
serialbandCommented:
I think that's up to your personal preference.  I've seen both.  You just need to be consistent, especially in a group, so you always know where to find it.
savoneCommented:
Exactly as above. There is no difference it is a personal preference. I personally prefer crontab -e.
AXISHKAuthor Commented:
Tks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.