DevOps

Cron Job (Automate Scheduled tasks Using )

devops_techaid71
Avatar of shohal
Written by shohal

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.

Cron Job (Automate Scheduled tasks Using ) | TechTweet
Cron Job (Automate Scheduled tasks Using ) | TechTweet

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

  }

}

🚀
Cron Job (Automate Scheduled tasks Using ) | TechTweet

If you’d like me to proceed with any of these, please just let me know from the site techtweet.xyz! Also if you need to learn something new than subscribe YouTube : ASP.NET With SQL SERVER

About the author

Avatar of shohal

shohal

I have profession and personal attachment with custom ERP Software development, Business Analysis, Project Management and Implementation almost (36) ,also Oracle Apex is my all-time favorite platform to developed the software. Moreover i have some website development experience with WordPress. For hand on networking experience DevOps and CCNA, it create me a full package. Here are some core programming language with networking course i have been worked: Oracle SQL ,PL/SQL,Oracle 19c Database , Oracle Apex 20.1,WordPress,Asp.Net ,MS SQL ,CCNA ,Dev Ops, SAP SD