Fail to run filebot with cron

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
valantislevas
Posts: 1
Joined: 28 Sep 2023, 09:06

Fail to run filebot with cron

Post by valantislevas »

Hello and thanks for this service.

I use the filebot on my server and it works very well the problem starts if i want to run the command with cron.

I provide some logs if someone can help me how to fix that. The problem is i think about enviroment vars or something but i cant make it work.

Shell: Select all

root@Ubuntu-2004-focal-64-minimal-hwe ~ # filebot -version
FileBot 5.1.1 (r9982) / Groovy 4.0.14 / OpenJDK Runtime Environment 17.0.8 / Linux 5.15.0-71-generic (amd64)

Shell: Select all

root@Ubuntu-2004-focal-64-minimal-hwe ~ # java -version
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment Temurin-17.0.8+7 (build 17.0.8+7)
OpenJDK 64-Bit Server VM Temurin-17.0.8+7 (build 17.0.8+7, mixed mode, sharing)

Shell: Select all

root@Ubuntu-2004-focal-64-minimal-hwe ~ # which filebot
/usr/local/bin/filebot
root@Ubuntu-2004-focal-64-minimal-hwe ~ # which java
/usr/local/bin/java

my simple script tha i want to run

Shell: Select all

#!/bin/bash
/usr/local/bin/filebot -rename -r "/home/seeder/googledrive/Greek-TV/H-Magissa" --db TheTVDB -non-strict --lang ell --format "{n} - {s00e00} - {t}{subt}"
echo "rename script finished"
i am on my root folder and when i run ./run_filebot.sh it works!

On cronjob when i put it like this:

Shell: Select all

39 11 * * * . $HOME/.profile; /root/run_filebot.sh >> /root/filebot.log 2>&1
my log file it says

Shell: Select all

/usr/local/bin/filebot: 55: java: not found
rename script finished
can someone help me to make it work?
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Fail to run filebot with cron

Post by rednoah »

. $HOME/.profile is problematic for multiple reasons:

:?: What is $HOME? Does cron guarantee that the $HOME environment variable is set? I don't know the answer to these questions, so I'd side-step the issue by using absolute paths instead.

:?: What does your . or source do exactly? Does it use export to export environment variables to child processes?



:arrow: You'll want to start debugging by doing printenv > /tmp/printenv.txt and then compare & contrast. You will likely find out that $PATH is different, i.e. /usr/local/bin missing from the default $PATH used by cron, which can easily be fixed by adding /usr/local/bin to the $PATH at the beginning of your script before calling filebot or java or any other program in there:

Shell: Select all

export PATH="/usr/local/bin:$PATH"
:arrow: Shell Script Debugging for Beginners will explain things in detail.
:idea: Please read the FAQ and How to Request Help.
Post Reply