0

I try to create a cron command that execute a software in a screen during start-up on my Debian. It seems easy by doing this command but it doesn't work (no screen created during start-up):

root@xxxx> crontab -u user_name -e
@reboot /usr/bin/screen -d -m rtorrent

This line seems to not work (I tried using "@reboot /usr/bin/screen -dmS torrent rtorrent" but same result: no screen created).

I'm sure the command is working because launching it without crontab works perfectly (but will not automate the launch during start-up):

user_name@xxxx> /usr/bin/screen -d -m rtorrent
(Result: The screen is created)

Note:

root@xxxx> cat /etc/shadow |grep user_name
user_name:!:16694:0:99999:7:::

root@xxxx> cat /etc/passwd |grep user_name
user_name:x:1004:1004::/home/user_name:/bin/bash

I hope you have an idea because I can't find any logical explanation about this behaviour :'(

Cheers,

Quentin

  • Have you tried changing @reboot to * * * * * to see if it triggers every minute? Most likely an incorrect path or typo or cron isn't running. – jecxjo Jan 28 '16 at 16:45
  • Yes: With @reboot I get one line in /var/log/syslog: Jan 28 16:20:36 sd-42901 CRON[386]: (torrent) CMD (/usr/bin/screen -d -m rtorrent) With "* * * * *", I get one every minute: Jan 28 17:47:01 sd-42901 CRON[7834]: (torrent) CMD (/usr/bin/screen -d -m rtorrent) Jan 28 17:48:01 sd-42901 CRON[7863]: (torrent) CMD (/usr/bin/screen -d -m rtorrent) Jan 28 17:49:01 sd-42901 CRON[7895]: (torrent) CMD (/usr/bin/screen -d -m rtorrent) – Quecg2 Jan 28 '16 at 16:52
  • 1
    Have you tried the full path for rtorrent? – jecxjo Jan 28 '16 at 16:55
  • Thanks a lot, it is indeed the solution: @reboot /usr/bin/screen -d -m /usr/local/bin/rtorrent – Quecg2 Jan 28 '16 at 17:01
0

Depending on your system your environment variables may not be set. You can either call everything using their full path or add your environment variables by hand. To do this (per man 5 crontab) you can insert variables at the top of your crontab in the standard KEY = VALUE layout

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

@reboot screen -d -m rtorrent

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.