1753929 Members
8431 Online
108810 Solutions
New Discussion юеВ

Cronjob's file

 
SOLVED
Go to solution
Shivkumar
Super Advisor

Cronjob's file

Hi,

Cron jobs store crontab's config entry
temporarily in a file /tmp/xxxxx and do not store the cron scheduled jobs
in a regular file system.

I have seen some system where cron jobs entries are stored in a text files.
Eg. /opt/somedir/somefile and then "/opt/somedir/somefile" file which contains the cronjobs to be scheduled are invoked by executing the command "crontab /opt/somedir/somefile"

Can someone suggest what should be best and safest practice ?

Thanks,
Shiv
7 REPLIES 7
Marco A.
Esteemed Contributor

Re: Cronjob's file

Well, the main directory for that is the /usr/lib/cron, but actually you could have your cron's in another locations and invoke them using the contab command, it is not about safetly or not, it depends of you, and how you want to manage your cron jobs.

look more about crontab at. :
http://www.informatik.uni-frankfurt.de/doc/man/hpux/crontab.1.html

Hope this helps,

Marc0
Just unplug and plug in again ....
Pete Randall
Outstanding Contributor

Re: Cronjob's file

I keep the cron job in the user's home directory: for root it's /root/cron.root, for a regular user it's /home/user/cron.user (though I rarely, if ever, allow users access to cron).


Pete

Pete
Patrick Wallek
Honored Contributor
Solution

Re: Cronjob's file

ALL cron jobs are stored, in HP-UX, in /var/spool/cron/crontabs and each user that has set up cron jobs, via the crontab command, has a file in that directory.

I'm not sure what you mean by "Cron jobs store crontab's config entry temporarily in a file /tmp/xxxxx and do not store the cron scheduled jobs in a regular file system." Perhaps you are talking about while you are editing a crontab file?

For information on cron, crontab, and at do:

# man cron
# man crontab
# man at
A. Clay Stephenson
Acclaimed Contributor

Re: Cronjob's file

My preference is to let the system store them as extract them as needed:

crontab -l > /var/tmp/mycrontab
vi /var/tmp/mycrontab and make any changes necessary
crontab < /var/tmp/mrcrontab # to read in the updated crontab file and signal the cron daemon that a change has occurred.

WARNING: DON'T DO THIS:
crontab

The command is waiting for input and when you hiyt Ctrl-C or Ctrl-D you just created an empty crontab and lost your original.
If it ain't broke, I can fix that.
Shivkumar
Super Advisor

Re: Cronjob's file

Yes Patrick, You are right. I meant while editing a crontab file it stores in /tmp/xxxxx.

Why it does so instead of reading and editing from /var/spool/cron/crontabs ??

Best Regards,
Shiv
Steven E. Protter
Exalted Contributor

Re: Cronjob's file

Shalom,

Those look like at job entries for Linux to me.

HP-UX stores cron files in /var/spool/cron

The name of the file is the user name. It looks just like what you'd get by invoking the command

crontab -e

Any other way of storing jobs is not cron and results from either system alteration or some third party software that is not cron.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Cronjob's file

HI SHiv:

> I meant while editing a crontab file it stores in /tmp/xxxxx. Why it does so instead of reading and editing from /var/spool/cron/crontabs ??

If you do 'crontab -e' the a temporary file is created automatically for the purposes of the edit session. The name of this tempoary file is generated by the system by 'mktemp()' and represents a unique string ending in the process id of the 'crontab'.

Regards!

...JRF...