The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Quick Cron Question

Discussion in 'Data Protection' started by lamans, May 19, 2006.

  1. lamans

    lamans Member

    Joined:
    Mar 17, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  2. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    yep, yes and sure can. create a script and then point the cron so that it runs the script. :)
     
  3. lamans

    lamans Member

    Joined:
    Mar 17, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    how do u make a script just create a file with the commands in it...
     
  4. lamans

    lamans Member

    Joined:
    Mar 17, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  5. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    what OS are you running?
     
  6. lamans

    lamans Member

    Joined:
    Mar 17, 2006
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Hiya

    Fedora core 4

    Thanks
     
  7. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    Looks to me like you need to save as '/home/user/script.sh' a script like
    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
     
Loading...

Share This Page