Cron job not executing

Hi. I'm new to FreeBSD and enjoying setting it up. Now this is probably a silly mistake by myself, but I can't figure out how to run my cron job.

As user I run 'crontab -e'. This is my crontab entirely:

Code:
@reboot /usr/local/bin/tmux new-session -d '/usr/local/bin/rtorrent'

I expected this command to run every boot as it executed fine from a shell and I used absolute paths.

But there is no tmux session running when I reboot. I tested a few different things out such as adding shebang and PATH variable:

Code:
#!/bin/sh
SHELL=/bin/sh
PATH=$PATH:/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
@reboot /usr/local/bin/tmux new-session -d '/usr/local/bin/rtorrent'

I also tried making a /var/cron/allow with my username in it.

Here is my cron log:

Code:
tail < /var/log/cron

Jan 11 10:35:51 salientdream crontab[4714]: (joe) BEGIN EDIT (joe)
Jan 11 10:35:54 salientdream crontab[4714]: (joe) END EDIT (joe)
Jan 11 10:36:00 salientdream /usr/sbin/cron[2528]: (joe) RELOAD (tabs/joe)
Jan 11 10:38:56 salientdream crontab[3418]: (joe) BEGIN EDIT (joe)
Jan 11 10:40:00 salientdream /usr/sbin/cron[3821]: (root) CMD (/usr/libexec/atrun)
Jan 11 10:40:04 salientdream crontab[3418]: (joe) REPLACE (joe)
Jan 11 10:40:05 salientdream crontab[3418]: (joe) END EDIT (joe)
Jan 11 10:41:00 salientdream /usr/sbin/cron[2523]: (joe) RELOAD (tabs/joe)
Jan 11 10:44:00 salientdream /usr/sbin/cron[5283]: (operator) CMD (/usr/libexec/save-entropy)
Jan 11 10:45:00 salientdream /usr/sbin/cron[5654]: (root) CMD (/usr/libexec/atrun)

The only other thing I can think of is that I have this setup to autologin my user. Could this be preventing the cronjob from executing? Thanks for reading.
 
Keep tailing:
tail -f /var/log/cron

And schedule it for every hour or so, so you don't have to reboot each time. See if removing that autologon helps.
 
Solved. I had to go to the end of the last line in my crontab and press enter to create a linefeed. Please mark this as solved for me as it seems I can't until I have enough posts. Thanks.
 
xtaz said:
FYI I usually test @reboot crons by just running:

# service cron restart

This has the same effect.

Thanks. That's useful to know, as I wasn't sure whether a service restart would work the same as at boot time.

Also, just adding absolute paths to executables in the cron job isn't enough. I had to add a path line like this:

Code:
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
@reboot /usr/local/bin/tmux new-session -d 'rtorrent'
 
Back
Top