Backup script runs but exhibits strange behavior - Ubuntu Server 16.04 LTS
Hi all,
I'm writing a backup script to backup the folders on a windows server. Basically, the script reads a text file for the windows folders, mounts them via mount.cifs then tars up the folders and as a backup report, it does a listing (tar -tf). The strange part that I can't understand is this: I can run the script from the command line as root. It works fine. I've tested the script with one line in the folderList.txt file (the list of folders) and with 3 lines. However, when I run the script as a cron job at 1:30am, although the script runs, it doesn't backup anything. As in, the script fires and the tarfiles are created, but they're all empty. I've also tested the cron job to fire in the middle of the day (e.g. 3pm) and it runs fine. Any ideas? Also where would the logs be (if there are any)? N.B. Before anyone comments, yes, I'm a Doctor Who fan (as evidenced by my choice of server name!) ;) Script is below: Code:
#!/bin/bash |
Next time put your script in [code] tags to make it readable.
This is covered time and time again. For any executable command you should specify /the/full/path/to/the/command |
Hmm. I'll try that tomorrow.
|
Set PATH at the beginning so every simple command is from there! (And your script remains short and readable).
Further, every $VAR in command arguments should be in quotes: "$VAR"! It avoids unwanted behavior if $VAR contains special characters. Examples Code:
FOLDER=`echo "$VAR" | cut -d '_' -f 2` |
All times are GMT -5. The time now is 06:31 PM. |