Operating System - HP-UX
1847012 Members
4115 Online
110258 Solutions
New Discussion

Migrate cron tab from TRU64 to HP UX 11.23 i

 
apple
Super Advisor

Migrate cron tab from TRU64 to HP UX 11.23 i

Dear HP-UX Gurus,
We wanted to migrate our cron jobs from TRU64 to HPUX 11.23i. Can I copy the crontabs folder to the new server? appreciate you could advice us the best way to migrate these cron jobs.

# /var/spool/cron/crontabs

Hope to hear from you
8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

The best way to to this is a crontab -l for each user on the source machine.

crontab -u user1 -l > /tmp/user1.crontab
crontab -u user2 -l > /tmp/user2.crontab

Then using tar, rcp, ssh, ftp, ... tranfer the /tmp/*.crontab files from the source machine to the target machine.

Finally, read in the crontab files for each user.

crontab -u user1 < /tmp/user1.crontab
crontab -u user2 < /tmp/user2.crontab

Simply copying the cron directory tree will not suffice because you have to force the cron daemon to actually read those files. The "crontab -u user1 < /tmp/user1.crontab" command actually does two things: 1) It reads the input into the cron tables 2) It sends a SIGHUP to the cron daemon to instruct the daemon to reread the configuration files.
If it ain't broke, I can fix that.
Kapil Jha
Honored Contributor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

I think folder copy is not a good idea.
Just copy the crontab files(root,oracle etc etc from /var/spool/cron/ directory) because crontab format is same and let HP-UX do its job.Its better to restart cron after copying.
Hope this help!!!
BR,
Kapil

I am in this small bowl, I wane see the real world......
Dennis Handly
Acclaimed Contributor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

>Clay: crontab -u user1 < /tmp/user1.crontab

I'm not sure about -u for Tru64 but the HP-UX syntax is: su user1 -c "crontab < /tmp/user1.crontab"
Only crontab -e -l -r support an optional user name:
crontab -e [username]

>It sends a SIGHUP to the cron daemon to instruct the daemon to reread the configuration files.

Would copying the folders and then using one crontab -e work??

Or just skip that and "kill -HUP cron-PID" be the easiest?
Kapil Jha
Honored Contributor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

>>>Would copying the folders and then using one crontab -e work??

Dennis I think it wont work because there are a lot of files
.proto..cronuucp
cronuucp
.proto..adm
.proto..sys
adm
sys
.new..cronuucp
.new..adm
.new..sys
.proto..root
root.rcm.bck
uucp -> ./cronuucp
.mrg..root
.new..root

which wont work with HP-UX !!!
>>>Or just skip that and "kill -HUP cron-PID" be the easiest?

This would be better because it would be similar to defining new crontabs for various users and forcing cron to reread the files.

BR,
Kapil
I am in this small bowl, I wane see the real world......
apple
Super Advisor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

Dear HP UX Gurus,
Sorry for the late reply. I was away during the weekend
How to restart the cron after copying in the new server? is it something like the cron service?
If I issue the copy by issuing the crontab -l command, will it cause the cron jobs to be temporarily stop or anything in the old server?
Hope to hear from you.




A. Clay Stephenson
Acclaimed Contributor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

No "crontab -l > mycronfile" will not cause the cron daemon to stop nor will "crontab < mycronfile" cause the daemon to stop. You can stop the cron daemon by "/sbin/init.d/cron stop" and restart it via "/sbin/init.d/cron start" BUT that is really the cowboy way. The most universal solution is to use the "crontab -l > mycronfile" command to extract the cron tables for each user and the "crontab < mycronfile" command to load the cron table for each user. The "crontab < mycronfile" command also implicitly sends a SIGHUP to the cron daemon to initiate a reread of the cron deamon's files so that no stop/restart is needed.
If it ain't broke, I can fix that.
apple
Super Advisor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

Dear HPUX Gurus,
once i migrated the cron jobs, how can i ensure it not activated yet as we need to finalised the cron jobs entry. once we confirmed, how can we start the cron jobs? is it by stop and start the cron job services.
looking forward for your awaiting reply.
promise of good points. tq
Dennis Handly
Acclaimed Contributor

Re: Migrate cron tab from TRU64 to HP UX 11.23 i

>once i migrated the cron jobs, how can i ensure it not activated yet as we need to finalised the cron jobs entry.

What do you mean by migrated? If you use the crontab command, the jobs will be executed.
If you meant you just copied the files into /var/spool/cron/crontabs, it won't be executed until you use crontab -e or the system is rebooted or cron restarted.

>how can we start the cron jobs?

You will need to do "crontab file" for each user. Or root can do what I mentioned above:
su user1 -c "crontab /tmp/user1.crontab"

>Clay: the "crontab < mycronfile" command also implicitly sends a SIGHUP to the cron

Actually it is a message in the FIFO /var/adm/cron/FIFO.