Cron job not found root user on stapp01

I believe I created a cronjob for all three app server for root user, but the system failed me. It only identified stapp01 and I used the same command for all three servers.
sudo yum install -y cronie
sudo systemctl start crond
crontab -e
—*/5 * * * * root echo hello > /tmp/cron_text

what is the error message. If possible could you please share the screenshot?

I have tested the lab and it is working as expected for me.

And also I have noticed that crontab -e should run with sudo to install cron for root user

crontab -e —> sudo crontab -e


Seems like you added the cron for user tony instead of user root. Either you should have switched to user root before running crontab -e or you could use sudo.

I hope that clarifies your doubt.


1 Like

It was my first time of failing a task so I did not realize I had to take a screenshot instead I was checking through it. However, since the screenshot is the criteria to prove accuracy, I guess this will be a learning curve for me.

*/5 * * * * root echo hello > /tmp/cron_text

          • [user] command
            I assume this is the right syntax and using sudo will not alter this command or switch the user that i have specified, rather sudo should provide the root privilege, which will give a denial of permission if it is needed.

this was the error; Required cron not found for root user on stapp01
However it did not say the same for stapp02 and stapp03 and I used the same commands

Dear @Inderpreet it is amazingly strange that I did create a new topic with this subject but I couldn’t find it back. Anyway it is may be better to post it here.
I had a task to create a cron job for the root user on all app servers. I thought I did it correctly I however received “Task Status -Failed”. And I really didn’t know the reason why. Would you check it please I attached you some screenshots.

Kind regards

hello @LuHa the error is that your cron is “hello”. The entire cron is supposed to be * / 5 * * * * echo hello> / tmp / cron_text. That is to say when you run the command $ crontab -l -u root, it should result to * / 5 * * * * echo hello> / tmp / cron_text.
There is no need to create a file cron_text.

However, I must confess that the question can be a little misleading if you don’t read it properly. As away if you have more doubts.

Thanks @Chudo for replying. You are right there was no need to create the file separately. The cron job will create it by itself if the file doesn’t exist. And I suppose if the file exists in advance the cron job uses it instead of creating a new one. That is what I understood. But as you see on the screenshots every 5 minutes the cron job assigned to the root user echoed the word hello on the specified file “/tmp/cron_text”

Hey @LuHa
Run me through every single command you used to solve the task. Let’s be sure if you were wrong or not.

Thanks again @Chudo Here are the steps I follow to execute the task

As requested on the task, I did this on all app servers

Install cronie package run the service named crond
sudo yum install cronie -y

Start and check the status of crond service
sudo systemctl start crond
sudo systemctl status crond

This was not necessary but I created in advance the cron_text file in the tmp folder
touch /tmp/cron_text

Add a cron job for the root user
sudo crontab -u root -e
*/5 * * * * echo hello >> /tmp/cron_text

Restart the service
sudo systemctl restart crond

Check if a cron job is created for the root user in cron directory
sudo ls /var/spool/cron

Of course this can be also checked using this command. But I didn’t use it.
crontab -l -u root

And after 5 minute, I checked the specified file (cron_text), whether the “hello” word is echoed on it
cat /tmp/cron_text

Not a problem at all.

From what I see, everything seems okay. So yes, ask @mmumshad @Inderpreet @kodekloud-support3 @kodekloud-support3 to check it out. I hope you get a satisfactory response in the end. Cheers!

Ok @Chudo many thanks. @mmumshad @Inderpreet @kodekloud-support3 would you please guys check my “Cron Job Creation” task I submitted on the 21st of May. You can see all the details on the conversation above.
And this was the requested task.

By the way I received the same task yesterday to create a cron job that is to be expired tomorrow morning. So, if it is possible for you guys would you please provide me a solution for this one before the new assigned task will got expired on me?

I am also facing the same issue. I followed the same steps on stapp02 & stapp03 …it worked fine but it is not working on stapp01 . Can you please look into this ?

same here…for some reason stapp01 fails…

as a remark, login into stapp01 did not work at the end…in the last lab minutes (after confirming task) tried ssh tony@stapp01, but it would not accept password.

Hello @Inderpreet in this task adding line */5 * * * * root echo hello > /tmp/cron_text to file /etc/cron.d/0hourly is a solution, i checked in each app server that the task was executed but i received a Fail. The only way to pass is by using crontab -e command or is accepted other way to obtain the same???
I only could have screenshots of stapp01 but this is the same in stapp02 y stapp03

I was able to make it work for all three app server. If it’s okay to share, here’s the commands I issued. Just modify first line for app svr 2 and 3.

sshpass -p ‘Ir0nM@n’ ssh -o StrictHostKeyChecking=no tony@
sudo yum install -y cronie
sudo systemctl start crond
sudo crontab -e

*/5 * * * * echo hello > /tmp/cron_text

sudo crontab -l -u root
sudo systemctl status crond
sudo systemctl restart crond
sudo cat /var/spool/cron/root