root cron job doesn't work (18.04 LTS SERVER)

As a root I run three dd processes in the background

dd if=/dev/urandom of=/dev/null &
dd if=/dev/urandom of=/dev/null &
dd if=/dev/urandom of=/dev/null &

As a root I edit a crontab and put a job to kill all dd processes that were run by root every minute

crontab -e
* * * * * pkill -u root dd 

But when I use top to monitor processes the dd processes don't get killed. Why ?

Messages from /var/log/syslog :

Dec 9 12:33:01 champion CRON[3395]: Authentication failure
Dec 9 12:33:29 champion crontab[3383]: (root) END EDIT (root)
Dec 9 12:34:01 champion cron[1432]: Authentication failure
Dec 9 12:34:01 champion CRON[3398]: Authentication failure

Tried these suggestions but it didn't help :

  1. Invoke the crontab with :

    crontab -e -u root

  2. Make sure that you have an empty line at the end of the cronjob file, meaning that every line ends with a newline.

9

2 Answers

Based on the following diagnostic output from pwck -r:

no matching password file entry in /etc/shadow add user 'root' in /etc/shadow?

you can see that the problem is the same as described here:

You can fix it by running pwck again, this time in read-write mode

sudo pwck

and accepting the suggested action to add the appropriate shadow file entry for user root.

1

Have you made sure you're writing the crontab with root?

sudo crontab -e

A non-root account would not be able to kill processes owned by root.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like