Operating System - HP-UX
1753479 Members
4955 Online
108794 Solutions
New Discussion юеВ

Re: Scheduling a cron Job

 
Saurabh Rawat
Advisor

Scheduling a cron Job

Hi Guys I have to schedule a cron job for whole content residing in a directory to another nfs mounted share. It has to be on daily basis. but the files under directory doesnt have any pattern. How should I do that?
Insanity is often the logic of mind overtasked!!!
7 REPLIES 7
Jeeshan
Honored Contributor

Re: Scheduling a cron Job

>>I have to schedule a cron job for whole content residing in a directory to another nfs mounted share.

what really you wanna do? not clear
a warrior never quits
Saurabh Rawat
Advisor

Re: Scheduling a cron Job

I mean I have to copy all the content under the directory to another directory.
Insanity is often the logic of mind overtasked!!!
Steven E. Protter
Exalted Contributor

Re: Scheduling a cron Job

Shalom,

Write a custom script to deal with the problem.

Then schedule it in cron.

Want something more specific? Give us something more specific.

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
Pete Randall
Outstanding Contributor

Re: Scheduling a cron Job

cd /source_dir
find . -print |cpio -pdumxl /target_dir

Put those lines in a script, then schedule the script with cron.


Pete

Pete
Saurabh Rawat
Advisor

Re: Scheduling a cron Job

hi

I have a directory /data/sm/ and under this reides several files e.g. /data/sm/file1 etc and I have to schedule acrom job to copy those files on daily basis to the directoy /copy/sm/
which should run daily.
Insanity is often the logic of mind overtasked!!!
jenith christopher
Occasional Advisor

Re: Scheduling a cron Job

Hi,

Add this in your script and put the crontab entry for the same

cp -pr /data/sm/* /copy/sm/.

It will copy the files and directories whatever under /data/sm/ to /copy/sm/

Hope you are familiar with crontab.
If you want more specfic.... reply


Regards,
Jenith Christopher.
Fredrik.eriksson
Valued Contributor

Re: Scheduling a cron Job

Just a quickie before anyone does anything wierd.

Does the files have the potential to be named the same as a file the day before?
If you cron it and the files share names they will be overwritten.

With that said,
-------------------
#!/bin/sh
# copy the files recursively and preserve file flags (permissions and such)
cp -pr /data/sm/* /copy/sm/

-------------------
and in crontab just write:
0 0 * * * /path/to/script

You can chage 0 0 to match the time you want to run it, the first one is hour and the other one is minute. That line will make it go off at 00:00 all days of all months. Make sure you chmod +x the script.

Best regards
Fredrik Eriksson