Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello to everyone in the group. I am a beginner with linux but have enjoyed adding this red hat box to my home network. So far I have a router and file sharing set up. I'm looking for a sample Cron script ( I think ) I want to set up a nightly backup for my windows laptop. If someone can point me in the right direction I'm much obliged.
regards and thanks
John

Does you unix machine have the samba client installed? Does smbtar do what you need it to
if you have a scsi tape drive as /dev/st0
you can use tar to back up a directory
tar cvf /dev/st0 /directoryname
smbtar allows you to do something similar with windows shares. Once you get the commands like you like them, write them to a file. Have cron execute this script you just wrote whenever you like
#----------8<--------cut here-------8<-------
#!/bin/sh
# sample smbtar.sh
# let's save this in /usr/local/bin/smbtar.sh
SERVER=windows_server_name
USER=username
PASSWD=password
TAPE=/dev/st0
/usr/bin/smbtar -s $SERVER -u $USER -p $PASSWD -t $TAPE
#----------8<--------cut here-------8<-------then add the line to your cron file
0 4 * * * /usr/local/bin/smbtar.sh
this will execute the script daily at 4:00 a.m. Make the script executable
chmod ugo+x /usr/local/bin/smbtar.sh
reference the online docs for smbtar for more information
man smbtar

Yes I do have samba installed and I can read all the correct directories. This looks like it will work fine. One question, does the cron script, smbtar.sh in the example above, have to be in a certain directory to be 'executed' at 4:00 am everyday? What exactly 'fires' it off everyday? Is it the fact that it has a .sh extension? I would like to understand this.
thanks again
jOhn

Unix does not look at the name to determine if a program or script can be executed. The command:
chmod ugo+x /usr/local/bin/smbtar.sh
would give execute priviledges (+x) to user (u), group (g) and other (o) so even someone that didn't own that file could execute it.
You might also see it written
chmod 755 /usr/local/bin/smbtar.sh
I just choose to end scripts with '.sh' so I can tell by looking it is a shell script and not a compiled binary.
The very first line '#!/bin/sh' tells the system to use the shell '/bin/sh' as the interpreter for this script. The same convention applies to perl scripts.
A program does not need to be in a certain directory, however if it is in a directory that is listed in your path, you would only need to type the script name and not the whole path to execute it. It is an accepted convention to store non-system executables in /usr/local/bin although nothing mandates it.
The system has a job that looks at each crontab file every minute to determine if any time based jobs need to be run. Having that entry in your crontab file ( should be in /var/spool/cron/crontabs/yourusername ) is enough to have it run automatically. You can edit your crontab file by typing
crontab -e
man crontab
will tell you more about what you can do with job scheduling.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |