Ubuntu :: Rsync Sh File Don't Work With Cron
Mar 25, 2011
I have a backup sh file that I have been using for a long time. It has always worked. 2 Days back I switched to a different pc and now suddenly the script don't work.If I run it manually in the terminal it works. But when it execute with cron it doesn't copy any files to the backup destination. It starts but doesn't copy anything.Can someone help me as to why it works manually but not with cron ?
View 9 Replies
ADVERTISEMENT
Dec 8, 2010
I'm using Ubuntu 10.04 LTS server and Postgresql 8.4. I have a .sh script that is run by cron every other hour. That works fine. The .sh script includes an rsync command that copies a postgresql dump .tar file to a remote archive location via ssh. That fails when run by cron; I think because it is (quietly) asking for the remote user's password (and not getting it). I set up the public/private ssh key arrangement. The script succeeds when run manually as the same user that the cron job uses, and does not ask for the password. I am able to ssh to the remote server from the source server (using the same username) and not get the password prompt (both directions), so why doesn't rsync work? I even put a .pgpass file in the root of that user's directory with that user's password, and the user/password are identical on both servers.
I think the problem is rsync is not able to use the ssh key correctly. I tried adding this to my script but it didn't help.
Code:
Here is the rsync command embedding in the .sh script.
Code:
Here is the cron entry:
Code:
View 6 Replies
View Related
Mar 30, 2011
I am running a headless Ubuntu server accessed through Webmin. The server is running 10.4.2 64 bit version. I have a number of cron jobs including a simple back-up job which is:
Code:
rsync -av /media/server/ /media/backup/backup/
All of the other jobs run fine but for some reason this job which is scheduled to run each day at midnight does not run. If I SSH into the server and run the job manually it works fine.
The output of 'crontab -l' is:
@daily rsync -av /media/server/ /media/backup/backup/
11 3 * * * /etc/webmin/package-updates/update.pl
@daily tar czf /media/backup/serversystem.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/media --exclude=/sys /
@reboot inadyn --username ********** --password ********** --update_period_sec 600 --alias **********
@daily /etc/webmin/backup-config/backup.pl 12978522112842
The output of 'crontab -e' is:
Error opening terminal: unknown.
crontab: "/usr/bin/sensible-editor" exited with status 1
View 9 Replies
View Related
Feb 19, 2010
I've got a bash script that uses rsync via SSH to back up data from a remote webserver.
This script works fine when I run it myself but when it runs as a cron job I get the following error:
Code:
2010/02/20 08:15:01 [6786] Unexpected remote arg: user@www.server.com:~/www
2010/02/20 08:15:01 [6786] rsync error: syntax or usage error (code 1) at main.c(1219)
[code]....
View 9 Replies
View Related
Nov 14, 2010
I'm trying to set-up a cron job that uses rsync to transfer back files from a remote server. ssh on the remote server is running on port 12345 but this seems to be a problem. My script looks like this:
Code:
#!/bin/sh
RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
KEY=/home/username/.ssh/id_rsa.pub
[Code]...
View 6 Replies
View Related
Mar 16, 2010
I am making a backup on an ntfs disk, mounted with:
using the following command:
Running this (or rather the shell script containing it) from the command line is OK, but if I run it as a cron job, I get thousands of messages:
(without line breaks, actually).
These files are all ordinary files made under Windows; the above should read "offici�le stukken", and from the command line it does, but not in cron.
I guess I need to set an environment variable, but which one?
View 1 Replies
View Related
Aug 14, 2011
I would like to backup important files (totaling about 400GB) on my ext 4 RAID 5 array to an ext4 external hard drive over USB (external drive is mounted to /mnt. In the future I'd like to automate the process using rsync and cron so for now I'm using rsync to transfer the files. My problem is that using the rsync command like this: # rsync -Pr "/dir1" "/dir2" "/dir3" "/dir4" /mnt
rsync shows me the checks and transfers for awhile and then throws up an i/o error (wish I had a screenshot to show but I don't). When I ls /mnt I get a similar i/o error. I then check /dev for the drive and find that it no longer shows up. Originally the partition was /dev/sdc1. I tried unplugging the USB at this point, plugging it back in and mounting the drive back to /mnt, however it has now assigned it to (you guessed it) /dev/sdd1. I get the drive mounted and try the original rsync command again, hoping the first error was a fluke or some kind of one-time drive fart. This time it makes it quite a bit further and then throws up the exact same problem. Am I doing something terribly wrong here? As I said, I'm very new to bash so I'm not making some absolutely moronic, newbie mistake.
View 9 Replies
View Related
Jan 6, 2010
I've been trying to accomplish this on my own, but I can't seem to figure it out...
All I'm trying to do (for learning purposes) is to get a message to print out to a log file every 5 minutes.
This is on Ubuntu Server 6.06.
Logged in as root ( I know, I know, should have sudo'd, oh well... )
Created a new file with this in it:
Code:
Added this line:
Code:
( I wasn't sure the proper command to try every 5 minutes, but this is my latest iteration. I also started with just */5, and that didn't seem to work either. )
Saved and exited crontab.
Console reports:
Quote:
Using command: ps -ef | grep cron
Quote:
So I waited 10 minutes to be safe.... and saw no log file appear.
I checked this page here: [url]
I wasn't sure what it meant by the PATH= variable they wanted me to set, my /etc/crontab file states:
Code:
But I didn't know if it meant there, or in my crontab -e location, so after the first failed attempt, I added the line from that webpage as well to crontab -e:
Code:
Waited another 10 minutes to be safe, still nothing.
View 4 Replies
View Related
Mar 2, 2010
I have a problem with mp3blaster.
I want cron to act as an alarm clock: first, it plays an mp3 file and then it runs the speech synthesizer festival which tells me to get up and do stuff.
Now, mp3blaster doesn't do anything when I run it from cron, but festival works without problems.
I've found some possible causes for mp3blaster not working through cron. Someone suggested that pulseaudio is not started. This shouldn't be the problem for me, since I don't even have pulseaudio installed, and festival is playing sound without problems...
I don't know what I should do to make it work.
Here is my script - runalarm.sh:
Code:
I don't want to include the wakeup text here since it contains profanity.
The mp3 player could be another one too. mp3blaster happens to be the only player I know that is easy to run from console, like this "mp3blaster goodsong.mp3", without and playlist creation or other stuff like that.
I can run the runalarm.sh from SSH console and it works fine, the mp3 starts playing and festival speaks after that. When run from cron, festival starts speaking right away and no mp3 is heard.
View 7 Replies
View Related
Aug 18, 2010
I installed CentOS 5.4 on a virtual server to host the tool OpenVAS, which is used to execute vulnerability assessment.This tool is based on a master engine and thousand of plugins, each one doing a specific, little function.I wrote a cron that, every sunday, updates the list of these plugins to keep the system updated; this cron uses a tool's proprietary function that download the new plugins from a site using rsync.I was using the rsync 2.6.8-3.1 until last week, when I decided to install ALL the updates proposed by operating system itself (more than 170) and the whole list includes rsync 3.0.7-1.el5.rf (from rpmforge).
This monday, the log of the tool's function gave me a bad response about the impossibility to establish a connection with the remote server due to a connection timeout.Before doing the rollback of the system, I tried to understand what happened, so I started manually the function on a terminal and, together, I was watching the results using netstat -tuvnap, so I saw that there was an attempt of connection, between my server and the remote one, but the connection did not finish the three way handshake, because the state of connection was always "SYN_STAT".I tried to value the $RSYNC_PROXY variable, because there is a proxy between my server and the world, but the result was exactly the same, so I was forced to execute the rollback of the system, which works very well now!
View 3 Replies
View Related
Oct 6, 2010
I can't seem to get a cron job to work on my Fedora 11 box. When I check the logs, cron is actually working. In my /etc/crontab I have an entry to run the cron job on my Moodle installation:
30 * * * * wget -q -O /dev/null http://moodle.name.name/moodle/admin/cron.php
when I run crontab -l it is not showing me anything, I am confused
View 1 Replies
View Related
Jan 22, 2011
I have a problem with grep in my cron job:
A simple command like this doesn't work
Code:
Of corse I have tried with full path like this
Code:
Both of this scripts work fine when started from my shell. Unfortunately they don't work when executed from cron job, and I get an empty p.txt file.
Here is my crontab file:
Code:
Have any one of you faced this kind of problem before ?
View 3 Replies
View Related
Jun 1, 2010
I have a simple cron job that runs every night & I tested this manually by just running the command as root in bash and all worked fine. It took some time but the crob job finished and I got my results emailed to me perfect / as expected.
Here is root's cron job listing:
Code:
Now I noticed that I never ever got anything emailed to me the following day so I am wondering if perhaps the Cron daemon doesn't have permissions or has an issue running / executing the command rather than when I test the command as 'root'? When I view my logs, I can see the command being executed and don't see any errors however I don't get email results when Cron runs the job rather than me taking the command and running it manually in Bash...then it works. What am I missing?
Code:
View 9 Replies
View Related
Oct 25, 2010
Cron refuses to work when trying to sync with a network drive. I am trying to setup a cron job to backup a folder in my home directory ('/home/scratch') to a folder ('home/internet_backup') that is mounted (using nfs) to a network folder. The folder ('home/internet_backup') is mounted correctly to the network folder upon system startup, so this part works.
I created a simple bash file (rsync-shell.1.sh) that looks like this:
Code:
# backup the contents of 'scratch' (of 'internet' machine) into '/home/aa/internet_backup/'
# the latter folder ('/home/aa/internet_backup/') is mounted to 'developer' machine
rsync -av --exclude=".*" /home/aa/scratch /home/aa/internet_backup/
#
When manually running this bash file from my home directory (./rsync-shell.1.sh) everything works, and the contents are written to the destination folder. Yet, instead of running this manually, I wanted this to be executed by Cron every 30 min. so I first chmod +x this file, and then copied it (using sudo) to /root.
I then created the following using 'sudo crontab -e':
Code:
# m h dom mon dow command
10 * * * * /root/rsync-shell.1.sh
This is the same bash file illustrated above, yet, it doesn't work (files are not being written to the destination folder).
View 2 Replies
View Related
Mar 28, 2011
I have a computer that I would like to backup the home directory onto a server. I created a script called wien_backup.sh that contains the following:
#!/bin/bash -l
/usr/bin/rsync -rv --delete-after --ignore-errors -e /usr/bin/ssh root@wngr403-unix2:/home/ /space/systemimager/Wien/
where wngr403-unix2 is the computer I am backing up, and the script is ran from the server. If I run the script by itself, it works just fine. If I run it as a cronjob, the /var/log/syslog says it ran, but it does nothing.
View 6 Replies
View Related
Nov 23, 2010
What would happen if I place more than one shell script in the cron.weekly directory. would they run at the same time?
View 1 Replies
View Related
Oct 5, 2010
I created a very simple cron job for testing my first Linux system but It doesn't work. After open the crobtab file by typing crontab -e, I put a line like this to send email in every 2 minutes to report disk usage:MAILTO=dan@gmail.com*/2 * * * * du -s /homeI tried to restart cron several times but I still got nothing worked. /etc/init.d/crond restart
View 14 Replies
View Related
Jan 12, 2010
I am having some trouble setting up a cron job that creates a tunnel to my remote machine to work correctly on Ubuntu 9.10. The setup looks like the following:
(1) myscript.sh (executable)
Code:
#!/bin/bash
ssh -2 -x -i /home/user/.ssh/id_rsa.prv -L 3128:myremotemachine:3128 myaccount@myremotemachine
(2) crontab -e, added the following lines:
[Code]...
View 5 Replies
View Related
Jul 1, 2011
I have successfully backed up my files using a script to a remote server with a log file output.However the log file is appended each time.I wish to have a different log file each time with date and time and have yet to figure that part out.
View 2 Replies
View Related
Nov 17, 2010
Thought I'd post it here because it's more server related than desktop... I have a script that does:
[Code]....
This is used to sync my local development snapshot with the live web server. There has to be a more compact way of doing this? Can I combine some of the rsyncs? Can I make the rsync set or keep the user and group affiliations? Can I exclude .* yet include .htaccess?
View 6 Replies
View Related
Jan 7, 2011
When I run rsync --recursive --times --perms --links --delete --exclude-from='Documents/exclude.txt' ./ /media/myusb/
where Documents/exclude.txt is
- /Downloads/
- /Desktop/books/
the files in those directories are still copied onto my USB.
And...
I used fetchmail to download all my gmail emails. When I run rsync -ar --exclude-from='/home/xtheunknown0/Documents/exclude.txt' ./ /media/myusb/ I get the first image at url.
View 9 Replies
View Related
Mar 24, 2010
I'm always getting this error when I run the rsync command:
Code:
when I try to navigate the file:
Code:
it gives
Code:
View 2 Replies
View Related
May 16, 2011
I have an Ubuntu machine running NFS4 server and a plugapps (arch linux) machine connecting as the client. The plugbox is running an rsync job to backup the home directory from Ubuntu to a local USB HDD.
All of the files in the destination have owner nobody and group nobody.
Ubuntu /etc/exports:
Code:
/home 192.168.2.1/24(rw,sync,no_subtree_check,no_root_squash)
plugbox /etc/fstab
[Code].....
how I can mantain the file owners. I have the UID's and passwords sync'd between the two machines for both root and the user who's home dir is being backed up.
View 9 Replies
View Related
Apr 29, 2011
Can anyone tell me how i change the default domain name for cron?everything i cron runs it emails from and to user@com.com
this leaves me with a massive list of failed mails in postfix.i have mailto on my main crontab but i cant do it on all of them.
View 1 Replies
View Related
Jul 5, 2011
I have installed CPAN module Spreadsheet::WriteExcel, to generate some reports. Now when i execute my perl module from command line. it works fine and generates the excel file. When i put this module to be executed via cron, it doenst work and an email is generated. My entry in cron tab is as follows:2 14 * * * perl /scripts/postpaidRecon/postpaid.plThe email i receive in /var/spool/mail/root for module failure is:
Subject: Cron <root@kblhpw101> perl /scripts/postpaidRecon/postpaid.pl
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
[code]....
View 3 Replies
View Related
Dec 18, 2010
I have a system with couple of local user accounts. I setup /etc/profile with umask 027 so that I can use groups to control if users can access files they don't own. It works great but now I find that cron saves stdout and stderr redirections with an effective umask of 022 (everybody has read rights).My user cron tab looks like this:
Code:
SHELL=/bin/sh
# m h dom mon dow command
[code]....
View 4 Replies
View Related
May 26, 2011
Using Ubuntu Server 10.04 LTS. I'm new to Ubuntu and testing Rsync. I successfully copied 3TB of data from a Win7 machine to an MDADM Raid5 array. All appears to be fine. Used a Win app for the copy. I then deleted a 250GB folder on the Raid5 array and recopied the data using Rsync. Rsync was executed via a Putty session on a WinXP machine. The source was an eSata attached drive (same drive used for the big 3TB copy) and the destination was the same Raid5 array. That copied just fine. I bit verified it with a Win7 app. Perfect.
I then used the following Rsync script to copy a single 26GB file from that same eSata drive back to (what I intended to be) the Raid5 array:
Code:
neil@ANTECUBSV:/mnt$ rsync -r -a -v -e ssh --delete /mnt/disk1/Test/ /mnt/Test
sending incremental file list
created directory /mnt/Test
./ C_VOL-S300-b001.spf
sent 3020267622 bytes received 34 bytes 50760800.94 bytes/sec
total size is 3019898880 speedup is 1.00
neil@ANTECUBSV:/mnt$ cd raid
Note that only about 3GB copied. No error messages were posted to the putty session. I made a mistake in the Rsync command, creating the Test folder directly in the mount folder rather than the Raid array, as I intended. That is a little strange, yes, but I would not think it would cause a partial copy? The /mnt folder is on my system drive, which had about 34GB available space before the copy, so comfortably would have had 6GB or so after.
The eSata disk is mounted as /mnt/disk1
The Raid5 array is mounted as /mnt/raid
I then recopied the file to the correct intended destination on the Raid5 array, which has about 400GB free space (plenty).
Code:
neil@ANTECUBSV:/mnt/raid$ rsync -r -a -v -e ssh --delete /mnt/disk1/Test/ /mnt/raid/Test
sending incremental file list
./
deleting 2010-07-05 Backyard Birds/Thumbs.db
deleting 2010-07-05 Backyard Birds/
C_VOL-S300-b001.spf
sent 11105775462 bytes received 34 bytes 50366328.78 bytes/sec
total size is 11104419840 speedup is 1.00
neil@ANTECUBSV:/mnt/raid$ df -h
Note that only about 11GB was copied, and this was confirmed with an ls -l command. Now I am correctly copying the file to the Raid array but it is still incomplete. I then copied the file back to the /mnt folder to see if the problem reproduces:
Code:
neil@ANTECUBSV:/mnt/raid$ rsync -r -a -v -e ssh --delete /mnt/disk1/Test/ /mnt/Test
sending incremental file list
created directory /mnt/Test
./
C_VOL-S300-b001.spf
sent 26327927554 bytes received 34 bytes 56558383.65 bytes/sec
total size is 26324713984 speedup is 1.00
neil@ANTECUBSV:/mnt/raid$ cd /mnt/test
This time I got my full 26GB file. Why I might be getting inconsistent results? This is quite troubling of course. I'd also be interested in basic a command line Linux diff app (that does file directory as well as bit level checking) if one is available.
View 9 Replies
View Related
Mar 10, 2010
i am trying to transfer a file from my live linux machine to remote linux machine it is a mail server and single .tar.gz file include all data. but during transfer it stop working. how can i work and trouble shooot the matter. is there any better way then this to transfer huge 14 gb file over network,vpn,wan transfer. the speed is 1mbps,rest of the file it copy it.
rsync -avz --stats bkup_1.tar.gz root@10.1.1.22:/var/opt/bkup
[root@sa1 logs_os_backup]# less remote.log
Wed Mar 10 09:12:01 AST 2010
building file list ... done
bkup_1.tar.gz
deflate on token returned 0 (87164 bytes left)
rsync error: error in rsync protocol data stream (code 12) at token.c(274)
building file list ... done
code....
View 1 Replies
View Related
Nov 21, 2010
I am trying to run rsnapshot from cron via root's crontab file (crontab -e). If I run rsnapshot from the command line with sudo it works perfectly, however, if I run it from cron:
Code:
* * * * * /usr/bin/rsnapshot hourly >/tmp/crontab.out 2>/tmp/crontab.err
This does not work. The crontab.err file shows:
[Code]....
View 2 Replies
View Related
Mar 27, 2011
I have a script, echoSmart.sh:
Code:
#!/bin/bash
smartctl -a /dev/sda > /smartlogs/sda-$(date).txt
[code]....
View 3 Replies
View Related