I am trying to setup analytics for 2 domains. I used sitespeed.io for that. When I log into my Ubuntu server as root and run the shell script, the output is as I want.
But when I run it as a crontab, the command is not executed. The working directory it picks up is /root which is not correct as the docker-compose.yml file is located in the /home/administrator/ directory.
I am unable to figure out which part of the shell script is the reason for that.
Shell script:
dir=$PWD
cd /home/administrator/ && echo $dir
(cd /home/administrator/ && docker-compose run sitespeed.io https://example.com/ --graphite.host=graphite)
(cd /home/administrator/ && docker-compose run sitespeed.io https://example2.com/ --graphite.host=graphite)
Crontab code
*/10 * * * * /home/administrator/dataload.sh >> /home/administrator/dataload.log
Log file contains only /root
systemctl status cron gives the following.
Oct 31 09:50:01 ubuntu40new CRON[20119]: pam_unix(cron:session): session opened for user root by (uid=0)
Oct 31 09:50:01 ubuntu40new CRON[20120]: (root) CMD (/home/administrator/dataload.sh >> /home/administrator/dataload.log)
Oct 31 09:50:01 ubuntu40new CRON[20119]: (CRON) info (No MTA installed, discarding output)
Oct 31 09:50:01 ubuntu40new CRON[20119]: pam_unix(cron:session): session closed for user root
The commands in shell script are not getting executed.