View previous topic :: View next topic |
Author |
Message |
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2198
|
Posted: Wed Jan 25, 2012 12:27 pm Post subject: Cannot get unison to run from cron (solved) |
|
|
I'm attempting to setup my backup schedule by using unison. I'm trying to get the unison socket service to start via cron on the backup server. I have vixie-cron installed and running. Here is what the crontab looks like:
Code: | projector ~ # crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXX4uevWD installed on Wed Jan 25 07:17:17 2012)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
MAILTO=xxxx@xxxxx.com
#minute hour dayofmonth month dayofweek command
19 7 * * * /root/start_unison.sh |
The unison script has the correct permissions to be executable:
Code: | projector ~ # ls -la /root/start_unison.sh
-rwxrwx--- 1 root root 40 Jan 25 06:54 /root/start_unison.sh |
Here is the contents of the script:
Code: | projector ~ # cat start_unison.sh
#!/bin/bash --
unison-2.27 -socket 5377 |
I set the crontab to execute the script, watch the process list, and nothing happens. What am I doing wrong? _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim
Last edited by Bigun on Wed Jan 25, 2012 6:28 pm; edited 1 time in total |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2198
|
Posted: Wed Jan 25, 2012 1:19 pm Post subject: |
|
|
Code: | projector ~ # ls -la /usr/bin/unison-2.27
-rwxr-xr-x 1 root root 1308568 Jan 23 15:48 /usr/bin/unison-2.27
projector ~ # cat start_unison.sh
#!/bin/bash --
/usr/bin/unison-2.27 -socket 5377 |
Just tried it:
Code: | projector ~ # crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXX9A2DBu installed on Wed Jan 25 08:15:17 2012)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
MAILTO=bigun@pwnedclips.com
#minute hour dayofmonth month dayofweek command
18 8 * * * /root/start_unison.sh |
Code: | projector ~ # date
Wed Jan 25 08:19:29 EST 2012
projector ~ # ps -A | grep unison
projector ~ # |
No dice _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
Posted: Wed Jan 25, 2012 1:44 pm Post subject: |
|
|
Then it has to be permissions problem, now when I think of it I'm not sure cron can run your script with root rights. Not sure if cron can even descend to /root. Perhaps somebody with better knowledge about cron inner workings will chime in.
Have you tried to run this command from crontab directly, without wrapping it into a script.
BTW, Quote: | Unison is a user-level program: there is no need to modify the kernel or to have superuser privileges on either host. | Why are you trying to run it as root anyway? _________________ My Gentoo installation notes.
Please learn how to denote units correctly! |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2198
|
Posted: Wed Jan 25, 2012 2:50 pm Post subject: |
|
|
Jaglover wrote: | Then it has to be permissions problem, now when I think of it I'm not sure cron can run your script with root rights. Not sure if cron can even descend to /root. Perhaps somebody with better knowledge about cron inner workings will chime in.
Have you tried to run this command from crontab directly, without wrapping it into a script.
BTW, Quote: | Unison is a user-level program: there is no need to modify the kernel or to have superuser privileges on either host. | Why are you trying to run it as root anyway? |
I've tried running it directly with the same result.
As far as why I'm running as root is really for the purpose of permissions access. I'm attempting to setup a backup script with a variety of permission levels, owners, and groups. _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim |
|
Back to top |
|
|
jormartr Apprentice
Joined: 02 Jan 2008 Posts: 174
|
Posted: Wed Jan 25, 2012 6:27 pm Post subject: |
|
|
Try setting the log and logfile variables, maybe unison writes something there before dying... |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2198
|
Posted: Wed Jan 25, 2012 6:28 pm Post subject: |
|
|
jormartr wrote: | Try setting the log and logfile variables, maybe unison writes something there before dying... |
Oddly enough, as I was about to write this post I tried that and it worked, all I did was direct the output to a log like so:
Code: | unison -[options] &> /tmp/unison.log |
and it worked. Thanks! _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim |
|
Back to top |
|
|
jormartr Apprentice
Joined: 02 Jan 2008 Posts: 174
|
Posted: Wed Jan 25, 2012 8:10 pm Post subject: |
|
|
Maybe unison expects an interactive terminal... could you try the dumbtty option (or something like that). |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2198
|
Posted: Wed Jan 25, 2012 8:13 pm Post subject: |
|
|
jormartr wrote: | Maybe unison expects an interactive terminal... could you try the dumbtty option (or something like that). |
There's a -batch option that does a non-interactive way of syncing the files, but apparently will crap out if there is any output. _________________ "It's ok, they might have guns but we have flowers." - Perpetual Victim |
|
Back to top |
|
|
|