-
Notifications
You must be signed in to change notification settings - Fork 2
/
TASK_4-Create_a_Cron_Job.sh
83 lines (57 loc) · 2.46 KB
/
TASK_4-Create_a_Cron_Job.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
TASK 3 - Create a Cron job
The Nautilus system admins team has prepared scripts to automate several day-to-day tasks. They want them to be deployed on all app servers in Stratos DC on a set schedule. Before that they need to test similar functionality with a sample cron job. Therefore, perform the steps below:
a. Install cronie package on all Nautilus app servers and start crond service.
b. Add a cron */5 * * * * echo hello > /tmp/cron_text for root user.
-----------------------------------------------------------------------------------------------------------------
# since I need to add cron for root user
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
# however this did not worked -- showed permission denied
# so back to using the local creds on the app server
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
sudo yum install -y cronie
sudo systemctl start crond
sudo crontab -e
# then add this to the file
*/5 * * * * echo hello > /tmp/cron_text
# to verify,
sudo crontab -l -u root
sudo systemctl status crond
# 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
sudo cat /var/spool/cron/root
---------------------------------------------------------------------------------
# Now do the same for App Server 2
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
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 ls /var/spool/cron
sudo cat /var/spool/cron/root
---------------------------------------------------------------------------------
# Now do the same for App Server 3
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
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 ls /var/spool/cron
sudo cat /var/spool/cron/root
---------------------------------------------------------------------------------
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
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