Hello i am trying to run a cronjob as root. I have entered the cronjob. Using
sudo crontab -lshows no crontab for root. But using sudo nano crontab -e shows the command. The following is the line of the cronjob:
18 13 * * * root /usr/bin/rkhunter --cronjob --update --quiet
If anyone can help me get this running it would be great.
Thanks and keep leaping
sudo nano crontab -e
sudo crontab -e is what you probably want.
sudo nano crontab -e is probably editing a file name
crontab in the current directory.
Thanks this is very true. After using the command you stated is replied
[frog@frog ~]$ sudo crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
sudo crontab -l does display the command now but it does not run.
systemctl status cronie has returned
Apr 06 19:35:01 frog crond: (root) CAN'T OPEN (/etc/crontab): No such file or directory
Is that timestamp from before or after you created a crontab?
Have you tried restarting cronie?
The time is just the time at which I set the cronjob to run. I will restart cronie.
I got this output after restarting cronie and testing it again.
Apr 06 19:47:01 frog crond: pam_unix(crond:session): session opened for user root(uid=0) by (uid=0)
Apr 06 19:47:01 frog CROND: (root) CMD (root /usr/bin/rkhunter --cronjob --update --quiet)
Apr 06 19:47:01 frog CROND: (root) CMDOUT (/bin/sh: line 1: root: command not found)
Apr 06 19:47:01 frog CROND: (root) CMDEND (root /usr/bin/rkhunter --cronjob --update --quiet)
Apr 06 19:47:01 frog CROND: pam_unix(crond:session): session closed for user root
It has been ages since I have setup a cronjob since systemd timers have mostly replaced cron at this point.
However, I think it should be like this if it in the root crontab:
18 13 * * * /usr/bin/rkhunter --cronjob --update --quiet
Yes, it is working now thanks. i will look into the timers.