Any task that you schedule through crons is called a cron job. Cron jobs help us automate our routine tasks, whether they’re hourly, daily, monthly, or yearly.
Schedule
Scheduled value
5 0 * 8 *
At 00:05 in August.
5 4 * * 6
At 04:05 on Sunday.
0 22 * * 1-5
At 22:00 on every day-of-week from Monday through Friday.
Automate Scheduled task Using Cron Job
1.crontab -e
2.*/1 * * * * sh /home/ashadullah-shawon/script.sh
3.*/1 * * * 6 sh /home/ashadullah-shawon/script.sh
script.sh
#! /bin/bash
date >> date.txt
Automate Scheduled task Using Cron Job
1.#!/bin/bash
2.tar -czvf backup.tar.gz /data/test/
Basic Bash Script
#!/bin/bash
# A simple hello world example
greeting=”Hello”
name=”World”
echo $greeting $name
#!/bin/bash
read a
read b
echo $a $b
Basic Bash Script
#!/bin/bash
read a
read b
sum=$((a+b))
echo $sum
#!/bin/bash
read old_text
read new_text
find . -type f -exec sed -i “s/$old_text/$new_text/g” {} \;
Web Server Nginx
1.mkdir /var/www/html/web1.cloudageskill.com
2.mkdir /var/www/html/web2.cloudageskill.com
3.nano /var/www/html/web1.webdock.io/index.html
4.chown -R www-data:www-data /var/www/html/web1.cloudageskill.com
5.chown -R www-data:www-data /var/www/html/web2.cloudageskill.com
6.nano /etc/nginx/sites-available/web1.cloudageskill.com.conf
Web Server Nginx
server {
listen 80;
listen [::]:80;
root /var/www/html/web1.cloudageskill.com;
index index.html index.htm;
server_name web1.cloudageskill.com;
location / {
try_files $uri $uri/ =404;
}
}
Web Server Nginx
ln -s /etc/nginx/sites-available/web1.cloudageskill.com.conf /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/web2.cloudageskill.com.conf /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx
Web Server Nginx Load Balancer
upstream myproject {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
}
server {
listen 80;
server_name node.cloudageskill.com;
#uncomment for logs
#access_log logs/host.access.log main;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://myproject; # make sure port matches open port in node app
}
}