Find the answer to your Linux question:
Results 1 to 9 of 9
Hi, I need a cron job to implement in my CentOS server just to copy a tar archive to windows 2003 server. Could you tell me a script for that? ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160

    Red face Cron Job Just to Copy a Tar File to a Windows Server


    Hi,

    I need a cron job to implement in my CentOS server just to copy a tar archive to windows 2003 server. Could you tell me a script for that? In the web there are sample sripts for FTP copying but I need the cp -r command in the cron job.

    Thanks

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,851
    You need permissions on the remote server, then you can mount the remote filesystem using the smbmount command.

    If you don't have smbmount available, then you should install the samba tools package from your package manager.

    The process you should go through is:

    1. mount the remote file system
    2. copy the file (you can now use cp -r ... using the mounted directory as the target)
    3. unmount the remote file system.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160
    Thanks Roxoff !

  4. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,356
    Additional note:
    You might want to consider to use the above mentioned mount via autofs instead of a always available mountpoint.

    If you rely on the mountpoint to be always available, then you would need to monitor it.
    Because if it breaks for whatever reason and at any time: network hickup, someone disconnects and reconnects a network cable, etc
    then your cron will fail as a consequence.

    autofs will automatically mount that cifs share only when it is needed and then disconnect after 5min of no action.
    This is more resilient, because it remounts at every run of that cron.
    You must always face the curtain with a bow.

  5. #5
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160
    Thanks Irithori !

  6. #6
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160

    Thumbs up

    Hi,

    I wrote a script and it's functioning but I want to optimize it and verify that from you all. My CentOS server has a tar file for each day backup and there are seven backups for the week with seven tar file names and those overwrite weekly. So I have to add seven cron jobs and the script I wrote as follows

    #!/bin/bash
    mount -t cifs //192.168.101.26/Backup /mnt/share -o "user=user1,password=xxxxxx,domain=domain1"
    cp -r /home/amitha/Desktop/test /mnt/share
    umount -t cifs //192.168.101.26/Backup /mnt/share
    could I know whether my umount command is correct????

    Thanks

  7. #7
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,851
    It's close but not perfect. Take a look at the man page for umount. You can probably use:

    Code:
    umount /mnt/share
    Linux user #126863 - see http://linuxcounter.net/

  8. #8
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160
    Thanks Roxoff !

  9. #9
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160

    Cool

    Hi ,

    Finally I was able to make it working

    my shell script is
    ##!/bin/bash
    mount -t cifs //192.168.101.26/Backup /mnt/share -o "user=user1,password=xxxxxx,domain=domain1"
    cp -r /home/amitha/Desktop/test /mnt/share
    umount /mnt/share
    edited the cron file with

    crontab -e
    command, and added the cron job

    22 11 * * 5 /home/amitha/Desktop/mount.sh
    But I wanted to install the gnome-schedule-2.2.0 it is not in YUM when I enter
    ./configure; make; make install
    command it give the error
    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    checking for PYGTK... no
    configure: error: Package requirements (pygtk-2.0 >= 2.6) were not met:

    No package 'pygtk-2.0' found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    Alternatively, you may set the environment variables PYGTK_CFLAGS
    and PYGTK_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.
    make: *** No targets specified and no makefile found. Stop.
    make: *** No rule to make target `install'. Stop.


    I have tried this make command for several other packages as well, for those also I got this type of error

    Many thanks for your help !!!!!

    Amitha
    Last edited by amithad; 08-24-2012 at 06:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •