Read the statement by Michael Teeuw here.
Cronjob
-
This is my crontab:
# daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command 0 6 * * * pm2 reload mmAre you running
crontab -ewith sudo? Because you have to run it as the user that runs MM (= most likely without sudo).Edit: @Zwirbel: For me it works using a cronjob. See what I wrote above and if you have questions regarding crontab, just ask again.
-
Juhuiiiii, finally it worked. Many Thanks
I have always used the command
sudo crontab -eand with this it did not work.It works fine with the
crontab -ecommand and then0 6 * * * pm2 reload mmOnce again, thank you very much for your help!!!
-
Glad it worked! :smiling_face_with_open_mouth:
-
@CyruS1337 said in Cronjob:
I have always used the command sudo crontab -e and with this it did not work.
Just to clarify.
Normally you are user pi:
$ who am ISo
crontab -ewill work for the pi user.
Usingsudo crontab -ewill change the crontab for the root user.Now how can you tell what is what ?
For the user pi:
$ sudo crontab -l -u pi
which is the same as
$ crontab -l
For the user root:
$ sudo crontab -l -u rootFurthermore, when you have activated the root crontab, then the command will run as root, in the root (/) directory.
In this casepm2 reloadcommand will search for themm.shscript under/and will not find it.
Whereas when activated the pi crontab, themm.shscript will be searched in the/home/pidirectory, where it should be, and it will work.Use
pm2 show mmto show the details on mm under pm2.
Then you will understand it better.Cron messages normally are directed to
/var/log/cron.log, but on my system it is not directed:$ grep cron /etc/rsyslog.conf #cron.* /var/log/cron.logTo see the cron messages, when not in cron.log:
$ tail -F /var/log/syslog | grep CRON[ On my system I see CRON messages for root, although I do not have root crontab entries. There is a crond running that runs alongside
$ systemctl status cron.]Have fun :-)
-
@evroom Many thanks for the detailed information.
As you can see, I always executed the command as sudo
sudo crontab -eSo I always executed the commands in the root directory. Which thus never led to success.
Thanks again for the help and the detailed listing.
Greeting
