deluge-console errors when using cron

General support for problems installing or using Deluge
Post Reply
mind0
New User
New User
Posts: 2
Joined: Tue Feb 03, 2015 6:28 pm

deluge-console errors when using cron

Post by mind0 »

Hi,

I have a script I run to setup port assignment on deluge which is failing only when running from cron. The important part is the last lines running deluge-console commands. The scripts runs without an error when running manually, but using a cron job it fails. Any help would be appreciated. thanks :)

crontab as user (log file added to collect errors)

Code: Select all

18 * * * * bash /home/alleyoopster/scripts/pia_portforward.sh >> /home/alleyoopster/pia_port.log

Code: Select all

#Get the local ip address 
VPN_IP=$(ifconfig $TUN|grep -oE "inet addr: *10\.[0-9]+\.[0-9]+\.[0-9]+"|tr -d "a-z :")
echo "Your VPN ipaddress is " $VPN_IP
echo Contacting PIA for port forwarding .......
TMP_PORT=$(curl -d "user=$USERNAME&pass=$PASSWORD&client_id=$(cat ~/.pia_client_id)&local_ip=$VPN_IP" https://www.privateinternetaccess.com/vpninfo/port_forward_assignment)

PORT=$(echo $TMP_PORT | sed "s/[^0-9]*//g")
echo "Port forwarding is currently using port "$PORT
echo "Changing port settings on deluge...."
deluge-console "config --set random_port False"
deluge-console "config --set listen_ports ($PORT,$PORT)"
When this is run in a cron job I get this error

Code: Select all

malformed expression (,)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/main.py", line 344, in do_command
    ret = self._commands[cmd].handle(*args, **options.__dict__)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/commands/config.py", line 104, in handle
    return self._set_config(*args, **options)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/commands/config.py", line 140, in _set_config
    val = simple_eval(options["set"][1] + " " .join(args))
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/commands/config.py", line 87, in simple_eval
    res = atom(src.next, src.next())
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/commands/config.py", line 56, in atom
    out.append(atom(next, token))
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/commands/config.py", line 79, in atom
    raise SyntaxError("malformed expression (%s)" % token[1])
SyntaxError: malformed expression (,)
mind0
New User
New User
Posts: 2
Joined: Tue Feb 03, 2015 6:28 pm

Re: deluge-console errors when using cron

Post by mind0 »

a little bump
noctividus
New User
New User
Posts: 8
Joined: Mon Jun 08, 2015 6:23 am

Re: deluge-console errors when using cron

Post by noctividus »

Were you able to solve this problem? I'm assuming cronie runs as root, which means it should execute commands as root.
noctividus
New User
New User
Posts: 8
Joined: Mon Jun 08, 2015 6:23 am

Re: deluge-console errors when using cron

Post by noctividus »

For those who come looking for answers, here's what I found to the best of my knowledge:

CRON can run as either root or a specific user depending on how you set it up. I assumed that running it as root would give it permissions to access the deluge-daemon. It doesn't you have to setup the cron job to run as the same user that deluge is running as.
Post Reply