Cron job to automate backup???? - Printable Version +- Linux Lite Forums (https://www.freecinema2022.gq/forums) +-- Forum: Development (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=7) +--- Forum: Scripting and Bash (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=32) +--- Thread: Cron job to automate backup???? (/showthread.php?tid=2484) Pages:
1
2
|
Cron job to automate backup???? - kjacobs - 12-14-2015 OK.....so I am trying to automate a weekly backup of my home folder. I did try the built in backup option in LL, but simply do not like the tons of zip files created during backup. I really only want mirror copies of the home folder on my NAS. I installed grsync to setup the backup......and the backup works fine. I then created a backup.sh file to run the grsync backup session, made it executable, and tested it......it works fine as well. Now I tried to add the script to a crontab job......this is where it all fails. I cannot get the file to run at all. I have tried MANY options.....I have added the path to the script to crontab.....tried adding the path in the script.......tried copying the script to the /bin folder.......tried standing on one foot while patting my head. I simply cannot get the file to launch using crontab. I have spent a number of hours looking up the correct formatting on google to get this right and it still fails to run. I also tried installing gnome-scheduler to do this in a gui and it fails to run as well. Soooooo, what in the world am I missing to get this function to run automagically???? Any help would be great......thanks. Re: Cron job to automate backup???? - firenice03 - 12-14-2015 I'm not a CRON expert but.... If not executing, maybe a permissions issue?? Any error's when running?? May have to pipe it out to a txt file to see errors.. Re: Cron job to automate backup???? - Wirezfree - 12-14-2015 Not sure if it's similar..?? I had some permissions issue trying to run some tasks... If you run gnome-scheduler from the System menu, The tasks are only run as "normal user". But if you open a terminal and do: Code: gksu gnome-scheduler It now run's as root, so anything you now schedule this way run's with root privileges. If you open Scheduler from the menu, you do not see the(se) root tasks. Re: Cron job to automate backup???? - kjacobs - 12-14-2015 Thanks for the replies......yes, I thought it might be a permissions things as well. I have a copy of backup.sh in a user folder with my user ownership and a copy in /usr/bin/ with root ownership. Neither one seem to run, yet I can double click either and it launches fine. All I seem to get in syslog for this line is this.... Dec 14 08:15:01 kenneth-OptiPlex-755 CRON[8245]: (root) CMD (/usr/bin/backup.sh) Dec 14 08:15:01 kenneth-OptiPlex-755 CRON[8244]: (CRON) info (No MTA installed, discarding output) I am not trying to mail anything, as the file should launch and I should see grsync start running when it hits the correct time. It looks like it is "trying" to run???? But nothing is happening.....maybe I am wrong here? Re: Cron job to automate backup???? - Wirezfree - 12-14-2015 Does any of this help: http://askubuntu.com/questions/222512/cron-info-no-mta-installed-discarding-output-error-in-the-syslog Re: Cron job to automate backup???? - kjacobs - 12-14-2015 Thanks for the tip.....that at least got some info on what is going on......got this from the mail file: Subject: Cron <root@kenneth-OptiPlex-755> DISPLAY=:0.0 /home/kenneth/bin/backup.sh # JOB_ID_3 Content-Type: text/plain; charset=ANSI_X3.4-1968 X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/root> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=root> Message-Id: <20151214165201.DA4455E165B@kenneth-OptiPlex-755> Date: Mon, 14 Dec 2015 08:52:01 -0800 (PST) No protocol specified (grsync:11062): Gtk-WARNING **: cannot open display: :0.0 Not sure what this means....LOL. Also tried it without the DISPLAY command......still did not start. Subject: Cron <root@kenneth-OptiPlex-755> /home/kenneth/bin/backup.sh >/home/kenneth/bin/text.txt # JOB_ID_3 Content-Type: text/plain; charset=ANSI_X3.4-1968 X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/root> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=root> Message-Id: <20151214164801.BDA305E165B@kenneth-OptiPlex-755> Date: Mon, 14 Dec 2015 08:48:01 -0800 (PST) (grsync:10646): Gtk-WARNING **: cannot open display: Re: Cron job to automate backup???? - firenice03 - 12-14-2015 Quote:(grsync:11062): Gtk-WARNING **: cannot open display: :0.0Looks like its trying to launch a GUI of sorts..???..?? http://askubuntu.com/questions/614387/gksu-gtk-warning-cannot-open-display-0 Another thought.. isn't CRON (sh) shell based and terminal is BASH... Not sure if this is still the case/true... But the script runs in terminal and fails in cron - I assume it fails from any shell window... Maybe its trying to prompt for roots PW?? Something like.. http://stackoverflow.com/questions/22704290/linux-cron-job-fails-to-execute-part-of-script-which-works-in-shell Hope it helps point in the right direction... Re: Cron job to automate backup???? - Wirezfree - 12-14-2015 I'm just stabbing in the dark.... Grsync is a GUI version of rsync.. Maybe that is the Gtk-WARNING cannot open display Maybe it's trying to output something GUI-wise but it is not running a gui..?? I'm probably not making sense... Can you not try just rsync..?? Re: Cron job to automate backup???? - Wirezfree - 12-14-2015 @firenice03 great minds, well hopefully great minds.... Re: Cron job to automate backup???? - firenice03 - 12-14-2015 (12-14-2015, 05:50 PM)Wirezfree link Wrote: @firenice03 Yours yes... Mine - I'm getting there 8) I'm good with "google".... Yeah - looks like the App is trying to access the display.. This may help..??.. http://promberger.info/linux/2009/01/02/running-x-apps-like-zenity-from-crontab-solving-cannot-open-display-problem/ |