Hi,
I have a workflow that I want to run automatically every day. It works fine when I run it command line:
knime -reset --launcher.suppressErrors -nosave -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowFile="/opt/knime/scheduled/MyWorkflow.knwf"
I put it in the crontab file yesterday:
0 1 * * * knime -reset --launcher.suppressErrors -nosave -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowFile="/opt/knime/scheduled/MyWorkflow.knwf"
but the expected result was not there this morning. What could be worng?
Thanks/Evert
Is it maybe a user related issue? When you run it in the command line your user is used. The cron - job runs as system user on default.
You must add the user command to the crontab
#<timing> <user> <command>
11 * * * * root /usr/lib/command
But it’s been quite a while since I was working on Linux machines.
Hmmm, I added myself and tried at 13:00 h but it did not work:
0 13 * * * evehom knime -reset --launcher.suppressErrors -nosave -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowFile="/opt/knime/scheduled/MyWorkflow.knwf" >/dev/null 2>&1
I just asked ChatGPT If you set up the job with “crontab -e” your user will be used automatically. I had it different in my mind.
Something like this should be sufficient:
0 14 * * * /PathToKNIME/knime > /home/username/knime_cron.log 2>&1 &
Maybe you have to add the full path to the KNIME installation. I would pipe the output to a log file to check for possible errors.
Cronjobs can be quite difficult to install as the environment with all the paths must be defined correctly. So maybe you have to source some settings in advance
Can’t seem to get it to work. I wrapped the full command in an all-executable file, which again runs fine when run directly but cron doesn’t like it for some reason…
@evert.homan_scilifelab.se you might want to try and use the full path also escaping possible blanks. Also make sure you have the script made executable.
Markus @mlauber71 is right. The “batch” File and the option “workflowDir” did the trick.
I created this File: RunMe.sh in my HOME folder
#!/bin/bash
/PathToKnime/knime -reset -nosave -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workFlowDir="/home/andi/knime-workspace/Test_Cron_Job"
Make this file executable with
chmod a+x RunMe.sh
Then I entered following in the crontab with “crontab -e”:
10 17 * * * /home/andi/RunMe.sh &
1 Like