rsync and vcron not working / permissions issue

I am not able to get vcron to start up rsync due to permissions. I have tested the rsync lines as a terminal in su and it works fine. However vcron will not run the script. I am pretty sure that it is due to permissions. What do I change in vcron to have it load as su so it can run the command? I have tried to modify the command line in the main menu to “vcron -su” (my guess), but still no success. Is there a group I can add this user to that would allow this? Thanks for your help.

Added information:

terminal running as super user - successfully runs rsync.

# rsync -alvz /boot/ /backup/boot-bak >> /backup/bootback.log

terminal running “sudo vcron” command.

dad@00-19-db-4a-4c-e9:~> sudo vcron
root's password:
Application initialization failed: no display name and no $DISPLAY environment variable
Error in startup script: can't read "tk_version": no such variable
    while executing
"if { $tk_version < "8.0" } {
    puts "vcron need tcl/tk version 8.0 mininum , aborting !"
    exit
}"
    (file "/usr/bin/vcron" line 17)
dad@00-19-db-4a-4c-e9:~> sudo vcron
Application initialization failed: no display name and no $DISPLAY environment variable
Error in startup script: can't read "tk_version": no such variable
    while executing
"if { $tk_version < "8.0" } {
    puts "vcron need tcl/tk version 8.0 mininum , aborting !"
    exit
}"
    (file "/usr/bin/vcron" line 17)

I do not know what vcron is, but as I see what you post is that you run vcron without any mentionin gt of the script. And vcron errors. Thus I do not see what the fact that your rsync command (not a script btw) runs has to do with the fact that vcron errors.

And it seems to me that vcron errors becaur it seems that it wants to open a window on a GUI session. But as it runs as root without a GUI that can not succeed. You can tell such a construction where the end-users session is and allow to open window there. In KDE you use kdesu and in Gnome gimesu. But I do not know a LXDE equivalent.

My guess is that you want to add the script (or the rsync statement) to root’s cron tab. You best do this via the CLI:

su -
crontab -e

You get then an editor (often vi) session where you can add the crontab line.

Thank you. To clarify, vcron (visual cron) is a tool that writes the cron tabs. See links below.
VCRON
vcron – Freecode

Below is the file that was written by vcron for the purpose of backups. It is located at /var/spool/cron/tabs

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (- installed on Wed Jan 16 16:47:05 2013)
# (Cronie version 4.2)
0 2 * * * rsync -alvz /boot/ /backup/boot-bak >> /backup/bootback.log
10 2 * * * rsync -alv /etc/fstab /backup/ >> /backup/fstab.log
12 2 * * * rsync -alv /etc/mtab /backup/ >> /backup/mtab.log
15 2 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /home /backup >> /backup/homebak.log
0 3 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /local/data1 /backup >> /backup/data1bak.log
30 3 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /local/VirtualBox /backup >> /backup/virtualboxbak.log
50 3 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /local2 /backup >> /backup/local2bak.log
10 4 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /moms /backup >> /backup/momsbak.log

If I run any of these lines (ie, rsync -alv /etc/fstab /backup/ >> /backup/fstab.log) as su in a terminal window, it will process the files to /backup. The problem is that they did not run at the time identified (last night starting at 2am). I apologize for my ingnorance, but I have not used cron other than with this app (vcron).

Is this cron tab formatted correctly?
Is the cron tab located in the correct drive?
Is there a diagnostic I can run that can provide you with any additional information?

Thanks for your help.

On 2013-01-17 00:16, idee wrote:
>
> Thank you. To clarify, vcron (visual cron) is a tool that writes the
> cron tabs. See links below.
> ‘VCRON’ (http://www.linux-kheops.com/pub/vcron/vcronGB.html)
> ‘vcron – Freecode’ (http://freecode.com/projects/vcron)
>
> Below is the file that was written by vcron for the purpose of backups.
> It is located at /var/spool/cron/tabs

To what filename exactly?

> Code:
> --------------------
> # DO NOT EDIT THIS FILE - edit the master and reinstall.
> # (- installed on Wed Jan 16 16:47:05 2013)
> # (Cronie version 4.2)
> 0 2 * * * rsync -alvz /boot/ /backup/boot-bak >> /backup/bootback.log
> 10 2 * * * rsync -alv /etc/fstab /backup/ >> /backup/fstab.log
> 12 2 * * * rsync -alv /etc/mtab /backup/ >> /backup/mtab.log
> 15 2 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /home /backup >> /backup/homebak.log
> 0 3 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /local/data1 /backup >> /backup/data1bak.log
> 30 3 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /local/VirtualBox /backup >> /backup/virtualboxbak.log
> 50 3 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /local2 /backup >> /backup/local2bak.log
> 10 4 * * * rsync -Calvz --exclude=Cache --exclude=tmp --exclude=temp --exclude=trash /moms /backup >> /backup/momsbak.log
> --------------------

IMHO, it would be better to call up a single script, and there run the
different rsync tasks one after the other. Thus each task will not
compete for resources if one takes too long.

> If I run any of these lines (ie, rsync -alv /etc/fstab /backup/ >>
> /backup/fstab.log) as su in a terminal window, it will process the files
> to /backup. The problem is that they did not run at the time identified
> (last night starting at 2am). I apologize for my ingnorance, but I have
> not used cron other than with this app (vcron).
>
> Is this cron tab formatted correctly?

yes, more or less. :slight_smile:

> Is the cron tab located in the correct drive?

What is a drive?

> Is there a diagnostic I can run that can provide you with any
> additional information?

You get a message in the log when each task starts. You can also get an
email with the output of each one.

One detail that you should know is that the environment a cron task gets
is minimal. For example, the path. Better give the full path to any
program you use.


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

. . . it is named the same as the user, in my case as “dad”.

IMHO, it would be better to call up a single script, and there run the
different rsync tasks one after the other. Thus each task will not
compete for resources if one takes too long.

. . . how would I do that?

Is the cron tab located in the correct drive?

What is a drive?

. . . sorry, the right location. It is at /var/spool/cron/tabs

One detail that you should know is that the environment a cron task gets
is minimal. For example, the path. Better give the full path to any
program you use.

It actually does have the full paths in each rsync line. /backups is a unique partitian, etc. Is that what you meant?

Thanks for your help, I look forward to learning how to set this as a script to run nightly.

On 2013-01-17 04:36, idee wrote:
>
> robin_listas;2518995 Wrote:
>> To what filename exactly?
>
> . . . it is named the same as the user, in my case as “dad”.

Then there you have your problem, it should be “root”, owned by root. I
guess that you have to call vcron after doing “su -”, not “su”.

>> IMHO, it would be better to call up a single script, and there run the
>> different rsync tasks one after the other. Thus each task will not
>> compete for resources if one takes too long.
>
> . . . how would I do that?

Huh?


MAILTO=dad
0 2 * * * /root/bin/dobackups

On /root/bin/dobackups you have:


#!/bin/bash
DATE=`date --rfc-3339=seconds`
echo "Starting backup at $DATE ======" >> /backup/bootback.log
rsync -alvz /boot/ /backup/boot-bak >> /backup/bootback.log
rsync -alv /etc/fstab /backup/ >> /backup/fstab.log
....

and of course, make it executable.

>> Is the cron tab located in the correct drive?
>>
>> What is a drive?
>
> . . . sorry, the right location. It is at /var/spool/cron/tabs

You don’t select the location, vcron does, I hope. Or you use something
like “crontab -e”.

>
>> One detail that you should know is that the environment a cron task gets
>> is minimal. For example, the path. Better give the full path to any
>> program you use.
>
> It actually does have the full paths in each rsync line. /backups is a
> unique partitian, etc. Is that what you meant?

No, I mean using “/usr/bin/rsync”.


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))

When this is in /var/spool/cron/tabs/dad, it is in the crontab of user dad. which is of course a normal end-user.

But you showed the running of the rsync statement as root (and that is probably correct, because you are doing a sort of backup of system files).

When you want these things to be run as root, you must put them in root’s crontab, not in the crontab of dad. Please think about that. When dad would be allowed to do the same things as root, that would be a severe sucurity breach!

And how to put them in root’s crontab, I showed you in my earlier post. That is not done using some GUI tool, but with

crontab -e

in a root terminal session.

Also I suppprt Carlos in that you shold consider creating a script putting those statements in. Put the script in the bin directory inside root’s home directory (/root/bin). Do not forget to make it executable. And then put a line in root’s crontab like

0 2 * * * /root/bin/<backupscript >/backup/backuplog-$(date) 2>&1

And like Carlos, I wonder what the word “drive” is doing in this discussion.

EDIT: I did not see Carlos last post above, but you will see that I in fact confirm what he says.

After “crontab -e”, it is now running. Thank you. I will look at the scripting as I get time.