Issue
I have geckodriver installed in the usr/local/bin
directory and exported to the $PATH variable.
export PATH=$PATH:~/usr/local/bin/geckodriver
You can see usr/local/bin
is in my $PATH
root/.rbenv/plugins/ruby-build/bin:/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
However, I run the ruby script by cronjob I get the following error message: Unable to find Mozilla geckodriver.
My Cronjob
*/20 * * * * ~/.rbenv/bin/rbenv exec ruby /home/path/to/the/ruby/script/report_export.rb
I start the ruby script so it all works. Can someone help me that it also works by cronjob
Solution
It could be that your export is located in place which is not called by cron daemon.
To investigate that replace your cronjob with echo $PATH >> /tmp/crontab.log
and then check '/tmp/crontab.log' for PATH and check if /usr/local/bin
is there.
Another reason could be that cron daemon is running as different user and thus has no access to geckodriver. Check ls -la /usr/local/bin | grep gecko
. If that's the case, please checkout this SO question
Answered By - Mark Huk