[FreeNAS] Setting up a cron task

Hello,
I tried to set up a backup of my windows computers to a FreeBSD server, using Rsync and cron through Freenas WebGUI. But nor the rsync service nor the cron jobs could work, and, moreover, I could not find an explanation for that. Thus I try now to implement the same process with FreeBSD command line.
I can access the FreeBSD server with an openssh console (in fact minty console) on my Windows desktop. The rsync command works now (thanks to some help from guys on this forum)

Code:
$ rsync -avz --delete Gabriel@192.168.1.103:/cygdrive/E/gabriel/ /mnt/RAID1A/gabriel/backup/mir_D83/gabriel
receiving incremental file list
deleting Essai/Guide d'Utilisateur.rtf
./
Guide d'Utilisateur.rtf
Essai/
sent 3061 bytes  received 982080 bytes  131352.13 bytes/sec
total size is 20771234648  speedup is 21084.53
I just moved one file in order to show that work is done.
Then I did put this command in a script (very basic, this is my first script ever)
Code:
#!/bin/sh
rsync -avz --delete Gabriel@192.168.1.103:/cygdrive/E/gabriel/ /mnt/RAID1A/gabriel/backup/mir_D83/gabriel
And this script works also, as it can be seen below
Code:
$ /mnt/RAID1A/gabriel/scripts/cron_mirror.sh
receiving incremental file list
deleting Essai/Guide d'Utilisateur.rtf
./
Guide d'Utilisateur.rtf
Essai/
sent 3061 bytes  received 982080 bytes  115898.94 bytes/sec
total size is 20771234648  speedup is 21084.53
Now I want to have the task done by a cron task. I searched some documentation on cron and crontabs, and tried to implement them, but it does not work and I would not make mistakes.
Apparently cron is running
Code:
freenas:~# ps auxw | grep cron
root    1878  0.0  0.1  3240  1056  ??  Ss    9:24AM   0:00.02 /usr/sbin/cron -s
root    6093  0.0  0.1  3364   940  p0  S+    3:42PM   0:00.00 grep cron
Where now should I put my cron task and how? The documentation and some posts here say to edit the right table with a command "crontab -e". But if I issue this command as is, I get "commnand not found". Should I specify the full path to a crontab ? But which one ?
I wish I could find a howto compatible with my FreeBSD 7.3 so that I don't bother people here, but the howtos I could find rarely say if they are obsolete or not!

:) Gabier
 
Check your PATH, the command should be inside the standard path.

Also verify your EDITOR settings, what's defined there is used as the editor.
 
SirDice said:
Check your PATH, the command should be inside the standard path.
The standard path is PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
I have checked in all these directories, there is no crontab command in them. How do I find where is this utility in order to add it in the path (with "setenv" command ?)
SirDice said:
Also verify your EDITOR settings, what's defined there is used as the editor.
The "setenv" command outputs EDITOR=nano. Is it OK?

:) Gabier
 
gabier said:
The standard path is PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
I have checked in all these directories, there is no crontab command in them. How do I find where is this utility in order to add it in the path (with "setenv" command ?)
crontab(1) is in /usr/bin/ and should be found according to your PATH

Code:
dice@molly:~>ls -al /usr/bin/crontab
-r-sr-xr-x  1 root  wheel  33928 Oct 29 14:43 /usr/bin/crontab

The "setenv" command outputs EDITOR=nano. Is it OK?
Should be fine if you can start nano from the command line. But this may be the issue though. Nano isn't installed by default. Try setting it to ee (I'm assuming you don't like vi) and see if crontab(1) works after that:
[cmd=]setenv EDITOR ee[/cmd]
[cmd=]crontab -e[/cmd]

If that works you'll need to adjust your ~/.cshrc and change EDITOR.
 
It would be good to put [FreeNAS] at the beginning of the thread title to make it clear. But you might also get better results for FreeNAS-specific questions on their forums.
 
SirDice said:
crontab(1) is in /usr/bin/ and should be found according to your PATH
Code:
dice@molly:~>ls -al /usr/bin/crontab
-r-sr-xr-x  1 root  wheel  33928 Oct 29 14:43 /usr/bin/crontab
No crontab in my /usr/bin/
Code:
freenas:~# ls -al /usr/bin/crontab
ls: /usr/bin/crontab: No such file or directory
Does this mean that Freenas 0.7.2 installation process does not install a full 7.3 FreeBSD Version ?

:) Gabier
 
gabier said:
Does this mean that Freenas 0.7.2 installation process does not install a full 7.3 FreeBSD Version ?
I have no idea. I'm a FreeBSD user, not a FreeNAS user.
 
wblock@ said:
It would be good to put [FreeNAS] at the beginning of the thread title to make it clear. But you might also get better results for FreeNAS-specific questions on their forums.
Yes, ou are right, but these forums could not help me to implement the thing through Freenas. So I thought that Freenas is in top of FreeBSD and that I could use FreeBSD's commands to do the same tasks (at least to understand what is going on). Maybe I am wrong to have thought that.
:) Gabier
 
In a way that is a good assumption but FreeNAS uses a heavily customized and stripped down (to the point of removing stuff like compilers afaik) version of the base operating system and means you'll have to consult those who are more familiar with FreeNAS.
 
kpa said:
In a way that is a good assumption but FreeNAS uses a heavily customized and stripped down (to the point of removing stuff like compilers afaik) version of the base operating system and means you'll have to consult those who are more familiar with FreeNAS.
OK, too bad, people are really pleasant here and quite responsive.

:) Gabier
 
If all else fails, you can edit /etc/crontab. This is the system crontab, and really shouldn't be edited by users (that's the whole point of separate user crontabs). But, if that's all that's available on FreeNAS, then that's what you'll have to use.
 
phoenix said:
If all else fails, you can edit /etc/crontab. This is the system crontab, and really shouldn't be edited by users (that's the whole point of separate user crontabs). But, if that's all that's available on FreeNAS, then that's what you'll have to use.
Thank you Phoenix, I tried that already, but this system crontab is restored at startup to its previous content. The user data are elsewhere.

:) Gabier
 
gabier said:
Thank you Phoenix, I tried that already, but this system crontab is restored at startup to its previous content. The user data are elsewhere.

So all you need to do is find out where they are being stored.
As I remember from my tinkerings with nanobsd there was a special config directory which was mounted on top of the rest of the system upon boot. All changes that you wanted to make had to be written to this directory. I think it was called /cfg but I'm not sure anylonger.
 
mix_room said:
So all you need to do is find out where they are being stored.
As I remember from my tinkerings with nanobsd there was a special config directory which was mounted on top of the rest of the system upon boot. All changes that you wanted to make had to be written to this directory. I think it was called /cfg but I'm not sure anylonger.
Thank you, mix_room, I do not know where this file could be. I defined a cron job in FreeNAS and searched where there were cron tables. I found the table was in /var/cron/tabs. I am also trying to have scripts of increasing complexity working through FreeNAS cron jobs. If I don't succeed to run my real script, I will try to change this table directly.

:) Gabier
 
Back
Top