rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.7k stars 122 forks source link

Chrome browser does not start, in cron. (Ubuntu) #346

Closed lunst97 closed 1 year ago

lunst97 commented 1 year ago

I have a code that downloads a file from a website, it only works with the setting (headless: false) otherwise it just doesn't download anything. I add the task of running the script to cron and I get this error (home/peeper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ferrum-0.13/lib/ferrum/browser/process.rb:157:in parse_ws_url: Browser did not produce websocket url within 10 seconds, try to increase :process_timeout. See https://github.com/rubycdp/ferrum#customization (Ferrum::Process Timeout Error) )

And this error is present only if you run the code from under cron, everything works in a normal console.

Cron: eval "$(~/.rbenv/bin/rbenv init - bash)" DISPLAY=:0 cd /home/peeper/xxx && /home/peeper/.rbenv/versions/2.7.2/bin/ruby main.rb

route commented 1 year ago

Meaning that you are running non-interactive shell? https://askubuntu.com/questions/503028/how-to-launch-interactive-shell-script-in-bash-hourly-with-cron