# Cron job inside jail



## scv (May 25, 2010)

Hi,

I have a problem with cronjob not executing bash script. It's a script that backups all my databases, sends them to mail and uploads them to ftp server. If i run script mannualy it works without any errors, I get mail, file is uploaded to ftp... 
MySQL server is inside jail. Well nothing gets executed from cron inside jail. Not even simple echo like

```
*/1  *    *    *    *    root    echo "Test" | mail -s "Test!" "scv@domain.com"
```

Cron is running

```
projekti# ps -A | grep cron
 8939  ??  IsJ    0:00.00 /usr/sbin/cron -s
 9122  p0  R+J    0:00.00 grep cron
```

For testing purposes I put it to execute every minute

```
*/1     *       *       *       *       backup  /home/backup/scripts/mysql.sh
```

Logs:

```
May 25 09:12:01 projekti /usr/sbin/cron[9055]: (backup) CMD (/home/backup/scripts/mysql.sh)
May 25 09:13:01 projekti /usr/sbin/cron[9077]: (backup) CMD (/home/backup/scripts/mysql.sh)
May 25 09:14:02 projekti /usr/sbin/cron[9109]: (backup) CMD (/home/backup/scripts/mysql.sh)
May 25 09:15:01 projekti /usr/sbin/cron[9142]: (backup) CMD (/home/backup/scripts/mysql.sh)
```


Any ideas?


----------



## SirDice (May 25, 2010)

Your cron syntax is wrong. See crontab(1).


----------



## DutchDaemon (May 25, 2010)

Also check your pathnames (to commands). Cron has a limited path (it doesn't have /usr/local/bin and /usr/local/sbin, for example).

See also:
http://forums.freebsd.org/showthread.php?t=12193
http://forums.freebsd.org/showthread.php?t=9871

Many more results in the forum search function.


----------



## anomie (May 25, 2010)

Also, I'm not sure '*/1' is legit. (At very least, it's redundant.)


----------



## jalla (May 26, 2010)

As SirDice says your syntax is wrong. Unless you use the system crontab (/etc/crontab) the username field should not be specified.

In general, as any output from cron is mailed to root it's usually quite easy to debug crontab problems by checking root's mail (or your own mail if you've done "the right thing" and aliased root to your regular user).


----------

