setup cron job to copy files

Posted on 2008-11-10
Last Modified: 2013-12-16
sorry i am very new to linux but need to copy files from one directory to another  every other day @ 1830

the cp command i have work out is

cp -f /var/www/html/admin/modules/core/etc/* /home/support

how do i create a cron to do this
Question by:James Murrell
    LVL 29

    Expert Comment

    to create a cron job you need to type

    contab -e


    have to give time when you want to copy .

    0 22 * * 0 cp -f /var/www/html/admin/modules/core/etc/* /home/support

    it wil copy your files at 10  pm every day

    just chagne the type to test as your need

    LVL 40

    Accepted Solution

    to add a crontab job, run

    export EDITOR
    crontab -e

    the above will give you temp file to edit using vi editor (with your current crontab jobs, if any)

    add line similar to

    30 18 */2 * * /usr/bin/cp -f /var/www/html/admin/modules/core/etc/* /home/support

    save and quit
    add the line t
    LVL 31

    Author Comment

    by:James Murrell
    add the line t ???
    LVL 40

    Expert Comment

    sorry, it is typo (cut and paste problem)
    LVL 29

    Expert Comment


    i just realized my answer was not fully correct because i didnot add /usr/bin before cp

    anyway, just a quick add: if you use /usr/bin cp -f  : it might not work because some time cp command is attached with only /bin directory.

    to find out where is cp : whereis cp  

    LVL 31

    Author Closing Comment

    by:James Murrell
    cheers that was a life saver
    LVL 14

    Expert Comment

    by:Deepak Kosaraju
    set the cron job under /etc/crontab as
    30 18 */2 * *  /bin/cp -f /var/www/html/admin/modules/core/etc/* /home/support

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now