I have a bash script named testScript.sh that looks like this :
#!/bin/bash curl -X GET https://www.example.com -o ~/Desktop/testFile.json curl -X POST -d ~/Desktop/testFile.json http://www.example2.com
i want to run this script with crontab so i edited crontab file with
crontab -e command like that :
* * * * * ~/Desktop/testScript.sh
The weird part is that when i run the script manually like
./testScript.sh with pi user, both curl commands execute just fine. When the script runs from crontab i see the testFile created so the first curl command execute, but the curl Post is not executed. I have already did my research and most of the people say it's environment variables but i don't seem to understand any of the answers.
EDIT* I followed @roaima suggestion to make a log file. Logs : ....Couldn't read data from file testFile.json", this make an empty Warning : post ....... the curl post then is giving me a 400 bad request because there is not content to post. 1) the testFile.json is created with the first curl command, i see it locally on my machine, i don't know why it cannot read it. 2) the script still runs fine if i run it like that./testScript.sh