I'm trying to run a command at certain intervals.
pm2 restart appname
Doing this myself works. Then I add it to a bash script.
#!/bin/bash pm2 restart appname
Running the bash script works:
Then I add it to my crontab:
* * * * * /usr/local/crontab-scripts/scriptname.sh >> /var/log/cronlog.log 2>&1
This gives me the error:
/usr/local/crontab-scripts/scriptname.sh: line 4: pm2: command not found
I'm not doing any of this as root, I have pm2 globally installed, I put into my script
whereis pm2 and it logged the correct path
/usr/local/bin/pm2. Then I tried having my script cd to that path before running pm2, no difference.
I'm out of ideas here.