lamans

Member
Mar 17, 2006
21
0
151
Hiya...

Quick question if i have files that are in say /backup and want to move them every day to another directory say /newbackup. I know i need to create a cron job but can i move them and change there ownership and permissions all in the one cron. If so do i just type the commands into a file like a batch file in DOS.. And then set a cron to run at whatever time i want... Any help would be apperciated.

With Thanks
 

lamans

Member
Mar 17, 2006
21
0
151
Hiya..

Ok here is what i want to do just want to see if anyone knows a more efficent command to do it.

cp -u /backup/*.tar.gz /newbackup/
chown -f me:me /newbackup/*

So if this was the most efficent way (i doubt it) would i just make a file and save it as say /home/user/me.sh
then i am going to want to run it in a cron everyday at 04:30

30 4 * * * /batch/me.sh

Just so its made clear i would then add this line to /etc/crontab

Any help would be apperciated.

Thanks
 

mctDarren

Well-Known Member
Jan 6, 2004
665
8
168
New Jersey
cPanel Access Level
Root Administrator
Looks to me like you need to save as '/home/user/script.sh' a script like
#!/bin/bash
cp -u /backup/*.tar.gz /newbackup/
chown -f me:me /newbackup/*
exit 0
and make sure to change the permissions on it so it will run properly. Then add it to your crontab as you said, although the path would have to match where you saved it (in your example you save to /home/user and run from /batch/).

HTH