Create Cron Job task wrongly failed me pls check

@Inderpreet @mmumshad

Failed due to — Required cron not found for root user on stapp01
but i did create cron in all app servers proofs below attached.
followed below steps on stapp01/stapp02/stapp03

sudo yum install cronie -y
systemctl start crond.service
systemctl status crond.service (showed active)

crontab -e
added below line in the crontab editor
*/5 * * * * echo hello >> /tmp/cron_text
got message cron tab installed
crontab -l
it gave out put
*/5 * * * * echo hello >> /tmp/cron_text

repeated this on stapp02/stapp03

as per me both tasks are completed on stapp01/stapp02/stapp03

please mark it as Success and i completed it under 48 minutes./

Commands executed:
thor@jump_host / ssh tony@stapp01 The authenticity of host 'stapp01 (172.16.238.10)' can't be established. ECDSA key fingerprint is SHA256:KyaxL+EPFYxGS/LcagN3PzmHnGuORgdp1cuqjG8b69E.ECDSA key fingerprint is MD5:25:c3:81:d9:4c:0f:4a:6b:2b:7b:f1:12:6c:f7:74:a5. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'stapp01,172.16.238.10' (ECDSA) to the list of known hosts. tony@stapp01's password: [tony@stapp01 ~] sudo su -

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for tony:
[root@stapp01 ~]# yum install cronie -y
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors

  • base: mirror.checkdomain.de
  • extras: mirror.checkdomain.de
  • updates: mirror.alpix.eu
    base | 3.6 kB 00:00:00
    extras | 2.9 kB 00:00:00
    updates | 2.9 kB 00:00:00
    (1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
    (2/4): extras/7/x86_64/primary_db | 205 kB 00:00:00
    (3/4): updates/7/x86_64/primary_db | 3.7 MB 00:00:00
    (4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:00
    Resolving Dependencies
    –> Running transaction check
    —> Package cronie.x86_64 0:1.4.11-23.el7 will be installed
    –> Processing Dependency: dailyjobs for package: cronie-1.4.11-23.el7.x86_64
    –> Running transaction check
    —> Package cronie-anacron.x86_64 0:1.4.11-23.el7 will be installed
    –> Processing Dependency: crontabs for package: cronie-anacron-1.4.11-23.el7.x86_64
    –> Running transaction check
    —> Package crontabs.noarch 0:1.11-6.20121102git.el7 will be installed
    –> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================
Package Arch Version Repository Size

Installing:
cronie x86_64 1.4.11-23.el7 base 92 k
Installing for dependencies:
cronie-anacron x86_64 1.4.11-23.el7 base 36 k
crontabs noarch 1.11-6.20121102git.el7 base 13 k

Transaction Summary

Install 1 Package (+2 Dependent packages)

Total download size: 141 k
Installed size: 260 k
Downloading packages:
(1/3): cronie-anacron-1.4.11-23.el7.x86_64.rpm | 36 kB 00:00:00
(2/3): cronie-1.4.11-23.el7.x86_64.rpm | 92 kB 00:00:00
(3/3): crontabs-1.11-6.20121102git.el7.noarch.rpm | 13 kB 00:00:00

Total 1.0 MB/s | 141 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : cronie-anacron-1.4.11-23.el7.x86_64 1/3
Installing : cronie-1.4.11-23.el7.x86_64 2/3
Installing : crontabs-1.11-6.20121102git.el7.noarch 3/3
Verifying : cronie-1.4.11-23.el7.x86_64 1/3
Verifying : cronie-anacron-1.4.11-23.el7.x86_64 2/3
Verifying : crontabs-1.11-6.20121102git.el7.noarch 3/3

Installed:
cronie.x86_64 0:1.4.11-23.el7

Dependency Installed:
cronie-anacron.x86_64 0:1.4.11-23.el7 crontabs.noarch 0:1.11-6.20121102git.el7

Complete!
[root@stapp01 ~]# systemctl start crond.service
[root@stapp01 ~]# systemctl status crond.servoce
Unit crond.servoce.service could not be found.
[root@stapp01 ~]# systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-07-31 20:35:58 UTC; 21s ago
Main PID: 185 (crond)
CGroup: /docker/a6027aad0e8d5c96ba4028b4492797e63ad277fe81d818c8567b86e0142cc044/system.slice/crond.service
└─185 /usr/sbin/crond -n

Jul 31 20:35:58 stapp01 systemd[1]: Enqueued job crond.service/start as 113
Jul 31 20:35:58 stapp01 systemd[1]: About to execute: /usr/sbin/crond -n CRONDARGS Jul 31 20:35:58 stapp01 systemd[1]: Forked /usr/sbin/crond as 185 Jul 31 20:35:58 stapp01 systemd[1]: crond.service changed dead -> running Jul 31 20:35:58 stapp01 systemd[1]: Job crond.service/start finished, result=done Jul 31 20:35:58 stapp01 systemd[1]: Started Command Scheduler. Jul 31 20:35:58 stapp01 crond[185]: (CRON) INFO (Syslog will be used instead of sendmail.) Jul 31 20:35:58 stapp01 crond[185]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 85% if used.) Jul 31 20:35:58 stapp01 crond[185]: (CRON) INFO (running with inotify support) Jul 31 20:35:58 stapp01 systemd[185]: Executing: /usr/sbin/crond -n [root@stapp01 ~]# crontab -e no crontab for root - using an empty one crontab: installing new crontab "/tmp/crontab.5fX4MO":1: bad hour errors in crontab file, can't install. Do you want to retry the same edit? yes crontab: installing new crontab [root@stapp01 ~]# crontab -l */5 * * * * echo hello >> /tmp/cron_text [root@stapp01 ~]# [root@stapp01 ~]# crontab -u root -l */5 * * * * echo hello >> /tmp/cron_text [root@stapp01 ~]# exit logout [tony@stapp01 ~] exit
logout
Connection to stapp01 closed.
thor@jump_host / ssh steve@stapp02 The authenticity of host 'stapp02 (172.16.238.11)' can't be established. ECDSA key fingerprint is SHA256:hLZ+SnF43yl05STCPg7NmoKQn8+Ct+3Hvtrbp48v9HI. ECDSA key fingerprint is MD5:03:96:15:90:3f:b1:0c:87:0b:fe:5a:9b:25:d5:42:97. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'stapp02,172.16.238.11' (ECDSA) to the list of known hosts. steve@stapp02's password: [steve@stapp02 ~] sudo su -

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for steve:
[root@stapp02 ~]# yum install cronie -y
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors

  • base: mirror.checkdomain.de
  • extras: mirror.checkdomain.de
  • updates: linux.darkpenguin.net
    base | 3.6 kB 00:00:00
    extras | 2.9 kB 00:00:00
    updates | 2.9 kB 00:00:00
    (1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
    (2/4): extras/7/x86_64/primary_db | 205 kB 00:00:00
    (3/4): updates/7/x86_64/primary_db | 3.7 MB 00:00:00
    (4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:00
    Resolving Dependencies
    –> Running transaction check
    —> Package cronie.x86_64 0:1.4.11-23.el7 will be installed
    –> Processing Dependency: dailyjobs for package: cronie-1.4.11-23.el7.x86_64
    –> Running transaction check
    —> Package cronie-anacron.x86_64 0:1.4.11-23.el7 will be installed
    –> Processing Dependency: crontabs for package: cronie-anacron-1.4.11-23.el7.x86_64
    –> Running transaction check
    —> Package crontabs.noarch 0:1.11-6.20121102git.el7 will be installed
    –> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================
Package Arch Version Repository Size

Installing:
cronie x86_64 1.4.11-23.el7 base 92 k
Installing for dependencies:
cronie-anacron x86_64 1.4.11-23.el7 base 36 k
crontabs noarch 1.11-6.20121102git.el7 base 13 k

Transaction Summary

Install 1 Package (+2 Dependent packages)

Total download size: 141 k
Installed size: 260 k
Downloading packages:
(1/3): cronie-anacron-1.4.11-23.el7.x86_64.rpm | 36 kB 00:00:00
(2/3): cronie-1.4.11-23.el7.x86_64.rpm | 92 kB 00:00:00
(3/3): crontabs-1.11-6.20121102git.el7.noarch.rpm | 13 kB 00:00:00

Total 1.3 MB/s | 141 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : cronie-anacron-1.4.11-23.el7.x86_64 1/3
Installing : cronie-1.4.11-23.el7.x86_64 2/3
Installing : crontabs-1.11-6.20121102git.el7.noarch 3/3
Verifying : cronie-1.4.11-23.el7.x86_64 1/3
Verifying : cronie-anacron-1.4.11-23.el7.x86_64 2/3
Verifying : crontabs-1.11-6.20121102git.el7.noarch 3/3

Installed:
cronie.x86_64 0:1.4.11-23.el7

Dependency Installed:
cronie-anacron.x86_64 0:1.4.11-23.el7 crontabs.noarch 0:1.11-6.20121102git.el7

Complete!
[root@stapp02 ~]# systemctl start crond.service
[root@stapp02 ~]# systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-07-31 20:41:12 UTC; 32s ago
Main PID: 183 (crond)
CGroup: /docker/6ffe97edabd3a7c3d4af62da4850bd0b3675b7de83caeaa554738bd9b0acb4e5/system.slice/crond.service
└─183 /usr/sbin/crond -n

Jul 31 20:41:12 stapp02 systemd[1]: Enqueued job crond.service/start as 121
Jul 31 20:41:12 stapp02 systemd[1]: About to execute: /usr/sbin/crond -n $CRONDARGS
Jul 31 20:41:12 stapp02 systemd[1]: Forked /usr/sbin/crond as 183
Jul 31 20:41:12 stapp02 systemd[1]: crond.service changed dead -> running
Jul 31 20:41:12 stapp02 systemd[1]: Job crond.service/start finished, result=done
Jul 31 20:41:12 stapp02 systemd[1]: Started Command Scheduler.
Jul 31 20:41:12 stapp02 crond[183]: (CRON) INFO (Syslog will be used instead of sendmail.)
Jul 31 20:41:12 stapp02 crond[183]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 53% if used.)
Jul 31 20:41:12 stapp02 crond[183]: (CRON) INFO (running with inotify support)
Jul 31 20:41:12 stapp02 systemd[183]: Executing: /usr/sbin/crond -n
[root@stapp02 ~]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[root@stapp02 ~]# crontab -l
*/5 * * * * echo hello >> /tmp/cron_text

[root@stapp02 ~]# crontab -u root -l
*/5 * * * * echo hello >> /tmp/cron_text

[root@stapp02 ~]# exit
logout
[steve@stapp02 ~] exit logout Connection to stapp02 closed. thor@jump_host / ssh banner@stapp03
The authenticity of host ‘stapp03 (172.16.238.12)’ can’t be established.
ECDSA key fingerprint is SHA256:KoLTlOYRCj+7M9Arc/lC/ZhqizwFSTuGTLFCh+6duiQ.
ECDSA key fingerprint is MD5:b1:63:62:ed:a2:f6:ca:71:c4:75:44:53:48:f3:11:34.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘stapp03,172.16.238.12’ (ECDSA) to the list of known hosts.
banner@stapp03’s password:
[banner@stapp03 ~] yum install cronie -y Loaded plugins: fastestmirror, ovl ovl: Error while doing RPMdb copy-up: [Errno 13] Permission denied: '/var/lib/rpm/Installtid' You need to be root to perform this command. [banner@stapp03 ~] sudo su -

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for banner:
Sorry, try again.
[sudo] password for banner:
[root@stapp03 ~]# yum install cronie -y
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors

  • base: mirror.checkdomain.de
  • extras: mirror.checkdomain.de
  • updates: mirror.alpix.eu
    base | 3.6 kB 00:00:00
    extras | 2.9 kB 00:00:00
    updates | 2.9 kB 00:00:00
    (1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
    (2/4): extras/7/x86_64/primary_db | 205 kB 00:00:00
    (3/4): updates/7/x86_64/primary_db | 3.7 MB 00:00:00
    (4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:00
    Resolving Dependencies
    –> Running transaction check
    —> Package cronie.x86_64 0:1.4.11-23.el7 will be installed
    –> Processing Dependency: dailyjobs for package: cronie-1.4.11-23.el7.x86_64
    –> Running transaction check
    —> Package cronie-anacron.x86_64 0:1.4.11-23.el7 will be installed
    –> Processing Dependency: crontabs for package: cronie-anacron-1.4.11-23.el7.x86_64
    –> Running transaction check
    —> Package crontabs.noarch 0:1.11-6.20121102git.el7 will be installed
    –> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================
Package Arch Version Repository Size

Installing:
cronie x86_64 1.4.11-23.el7 base 92 k
Installing for dependencies:
cronie-anacron x86_64 1.4.11-23.el7 base 36 k
crontabs noarch 1.11-6.20121102git.el7 base 13 k

Transaction Summary

Install 1 Package (+2 Dependent packages)

Total download size: 141 k
Installed size: 260 k
Downloading packages:
(1/3): cronie-1.4.11-23.el7.x86_64.rpm | 92 kB 00:00:00
(2/3): cronie-anacron-1.4.11-23.el7.x86_64.rpm | 36 kB 00:00:00
(3/3): crontabs-1.11-6.20121102git.el7.noarch.rpm | 13 kB 00:00:00

Total 1.3 MB/s | 141 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : cronie-anacron-1.4.11-23.el7.x86_64 1/3
Installing : cronie-1.4.11-23.el7.x86_64 2/3
Installing : crontabs-1.11-6.20121102git.el7.noarch 3/3
Verifying : cronie-1.4.11-23.el7.x86_64 1/3
Verifying : cronie-anacron-1.4.11-23.el7.x86_64 2/3
Verifying : crontabs-1.11-6.20121102git.el7.noarch 3/3

Installed:
cronie.x86_64 0:1.4.11-23.el7

Dependency Installed:
cronie-anacron.x86_64 0:1.4.11-23.el7 crontabs.noarch 0:1.11-6.20121102git.el7

Complete!
[root@stapp03 ~]# systemctl start crond.service
[root@stapp03 ~]# systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-07-31 20:44:51 UTC; 8s ago
Main PID: 188 (crond)
CGroup: /docker/decb1dfd333f274048109b81e50c0e1c72c1e2b6f9066c6b259a1432b0f783fd/system.slice/crond.service
└─188 /usr/sbin/crond -n

Jul 31 20:44:51 stapp03 systemd[1]: Enqueued job crond.service/start as 137
Jul 31 20:44:51 stapp03 systemd[1]: About to execute: /usr/sbin/crond -n $CRONDARGS
Jul 31 20:44:51 stapp03 systemd[1]: Forked /usr/sbin/crond as 188
Jul 31 20:44:51 stapp03 systemd[1]: crond.service changed dead -> running
Jul 31 20:44:51 stapp03 systemd[1]: Job crond.service/start finished, result=done
Jul 31 20:44:51 stapp03 systemd[1]: Started Command Scheduler.
Jul 31 20:44:51 stapp03 crond[188]: (CRON) INFO (Syslog will be used instead of sendmail.)
Jul 31 20:44:51 stapp03 crond[188]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 83% if used.)
Jul 31 20:44:51 stapp03 crond[188]: (CRON) INFO (running with inotify support)
Jul 31 20:44:51 stapp03 systemd[188]: Executing: /usr/sbin/crond -n
[root@stapp03 ~]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[root@stapp03 ~]# crontab -l
*/5 * * * * echo hello >> /tmp/cron_text
[root@stapp03 ~]# crontab -u root -l
*/5 * * * * echo hello >> /tmp/cron_t

@Sasi Remember the cron expression needs to be exactly same what is asked in the question. The cron expression as per question is */5 * * * * echo hello > /tmp/cron_text but the one you used is */5 * * * * echo hello >> /tmp/cron_text, notice the redirection.

well the Cron tab installation failed if i gave the format wrong like placing **** together or * /5 when i gave extra space between */5, so when Cron tab has successfully installed and crontab -u root -l gave the */5 * * * * echo hello >> /tmp/cron_text
i have thought all the formatting and content of the task has been given right.

what is the difference between > vs >> it did build the cron tab right? if the typo mistake caused like in below example #PermitRemotelogin no and if we didnt remove # that makes the settings are not saved those kind of mistakes can be considered failed.

in my case */5 * * * * echo hello is main content of the this task and whether we used > or >> it did echod the result back when i did crontab -l
or
crontab -u root -l

@Inderpreet pls consider this for a sucess or pls mark the task as pending for me please.

@Sasi

> creates a new file (target file) if it doesn’t exist and it replaces the content of original file if it already exists.
>> also creates a new file (target file) if it does’n exist but if the file exists it just appends the content of the file rather than replacing the entire old file.

In real time scenarios you need to use these redirections carefully as you may overwrite some important target file which can lead to data loss.

@Inderpreet well when i did the crontab -l or crontab -u root -l
it did displayed the actual content we needed in this cron job which is */5 * * * * echo hello
if the content of previous cron job is different than the content of this cron job we built then using > vs >> makes a big difference well in our case there is no other previous version or content of the file in that case using > vs >> does not make any difference

am i missing something. can you please mark it as success or atleast mark it as pending.

@Sasi I agree with that, it will display the same content in this case since there is no exiting file/data. These scenarios just resemble the real time scenarios/issues so you always need to stick to the requirements mentioned in the question otherwise task gonna fail for you.

@inderpreet okay thanks