Curl don't work on cron execution
Solution 1
I have solved the problem, were i was able to run script manually but when i tried from cron it failed with "curl: not found".
wherever you`ve written "curl" in your script put complete path.
How to find complete path.? Just run command on your machine "which curl" you`ll see path for curl and copy paste in your script.
Solution 2
When you run a script from the command line, your own environment variables, including $PATH, are in use. When you run a script from cron, however, the $PATH is different. My guess is that you don't have curl in a path that cron has in its $PATH environment variable.
Solution: In your script, use the full path to cron.
Related videos on Youtube
Filipiz
Updated on September 18, 2022Comments
-
Filipiz almost 2 years
I have bash a script like the following
#!/bin/bash date curl http://lab.nextt.com.br/somefile1.html -z ../public_html/somefile1.html -o ../public_html/somefile1.html --silent --show-error --location curl http://lab.nextt.com.br/somefile2.html -z ../public_html/somefile2.html -o ../public_html/somefile2.html --silent --show-error --location curl http://lab.nextt.com.br/somefile3.html -z ../public_html/somefile3.html -o ../public_html/somefile3.html --silent --show-error --location curl http://lab.nextt.com.br/somefile4.html -z ../public_html/somefile4.html -o ../public_html/somefile4.html --silent --show-error --location
and I have a cronttab like this
* * * * * /home/user/cronjobs/cronjob-updatefiles >> /home/user/cronjobs/log
My intention is: whenever there is an update on a public file, download it to my server.
So good so far.
When I run the script manually on the shel, the files are downloaded and updated as expected.
And the cron is running the... The /home/user/cronjobs/log is being updated with the date (on the beggining of the script). But the curl commands are not executed via cron. The files are not updated.
Why when I run directly on the shell it works and when I run via cron it does not?
-
Dennis Kaarsemaker over 11 years
-
-
Filipiz over 11 yearsYeah.. not only the full path to cron but also the full path of the files I was referencing... I posted the solution I found right now.. thank for helping!
-
Jenny D over 11 yearsI'm now feeling incredibly stupid for not getting that part, too. Thanks for the update!