0

this code works perfectly when executed manually using wdt.sh script, but when its executed by crontab, it executes everything except running qbittorrent. I ve tried using sudo chmod a+x wdt.sh, full path to the qbittorrent and many more.. but could not get it running. I am not very familiar with linux environment, and this project is running on RPI zero 2, where i am trying to run Qbittorrent to open a specific port, which will be opened and closed, based on if there is inline power or not. (var1 is current voltage to device and var2 is limit voltage in mA)

Someone suggested, that the problem could be related to graphical interface not popping when executed, which is related to cron x11, but i didnt find this helpful, no change to cron, or script made any change.

Ive tried to open the Qtorrent from cron directly using

    DISPLAY=:0.0
    * * * * * /usr/bin/qbittorrent

and it works fine, but when i do this to my script it wont. I ve also tried to put the DISPLAY entry into the script itself, with no effect.

Script:

    var1=$(wdt -g v)
    var2=1000
    date1=$(date -u)
    torr1=$(pgrep qbittorrent)
    if [ $(($var1)) -lt $var2 ]; then
        if [ $torr1 > /dev/null ]; then
            pkill qbittorrent
            echo $date1 ": PowerLoss" >> /home/pi/wdtlog
        fi
    elif [ ! $torr1 > /dev/null ]; then
            DISPLAY=:0.0
            qbittorrent
            echo $date1 ": PowerRestore" >> /home/pi/wdtlog     
    fi

Crontab :

    crontab -e    .....

    DISPLAY=:0.0
    * * * * * sudo /home/pi/wdt.sh
darksize
  • 9
  • 2
  • The problem is that you're trying to use a GUI application from cron. There are hundreds of examples if you search google for `cron X11`. – tink May 14 '22 at 18:50

0 Answers0