<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Prakhil Thottipully</title>
    <description>The latest articles on Forem by Prakhil Thottipully (@prakhil_tp).</description>
    <link>https://forem.com/prakhil_tp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F286912%2F1a6780f8-a826-4ef7-8e5c-222e64c9d5d1.jpeg</url>
      <title>Forem: Prakhil Thottipully</title>
      <link>https://forem.com/prakhil_tp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/prakhil_tp"/>
    <language>en</language>
    <item>
      <title>Add font ligatures to your Alacritty</title>
      <dc:creator>Prakhil Thottipully</dc:creator>
      <pubDate>Fri, 08 Apr 2022 04:54:17 +0000</pubDate>
      <link>https://forem.com/prakhil_tp/add-font-ligatures-to-your-alacritty-2fld</link>
      <guid>https://forem.com/prakhil_tp/add-font-ligatures-to-your-alacritty-2fld</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;This article helps you to enable font ligatures on your Alacritty terminal.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We know that Alacritty does not support font ligatures. However, we stick to it due to its performance excellence.&lt;/p&gt;

&lt;p&gt;Although, you have good news! Someone made it possible. See the fork of the Alacritty repository with the added font ligatures.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://github.com/zenixls2/alacritty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tl;dr
&lt;/h2&gt;

&lt;p&gt;To solve the problem, let's build the repository and install the output binary on our system. Below are the steps to your destiny.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repository and build it&lt;/li&gt;
&lt;li&gt;Backup the existing binary and install the new one.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to do it?
&lt;/h2&gt;

&lt;p&gt;Before we clone and build the repo, you should make sure you have the necessary build tools to build the application. The Rust is used to write the Alacritty. Therefore, you must ensure you have &lt;code&gt;cargo&lt;/code&gt; installed on your system&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;cargo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now, let's clone the repo using the below command.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/zenixls2/alacritty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use the following commands to build.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;alacritty
git checkout ligature
cargo build &lt;span class="nt"&gt;--release&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If all goes well, this should place a binary at &lt;code&gt;target/release/alacritty&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Install the binary
&lt;/h3&gt;

&lt;p&gt;We got the binary file after the build. Now, we only need to move it to the right place. For that, we should backup the existing binary file and use the new one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backup the existing binary using this command
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mv&lt;/span&gt; /usr/bin/alacritty /usr/bin/alacritty.bak
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then, let's copy our build binary to the &lt;code&gt;/usr/bin&lt;/code&gt; folder.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cp&lt;/span&gt; ./target/release/alacritty /usr/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Also make sure you have the right font-family on your alacritty config.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;font:
  normal:
    family: Fira Code
    style: Regular
  bold:
    family: Fira Code
    style: Bold
  italic:
    family: Fira Code
    style: Italic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There you go!&lt;/p&gt;

&lt;p&gt;Relaunch the terminal and see the magic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We have covered all the steps to enable the font ligatures on the alacritty terminal. Hope this article helps you.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>GitLab CI/CD: A guideline to set up your pipeline</title>
      <dc:creator>Prakhil Thottipully</dc:creator>
      <pubDate>Sun, 27 Sep 2020 18:34:46 +0000</pubDate>
      <link>https://forem.com/prakhil_tp/gitlab-ci-cd-a-guideline-to-set-up-your-pipeline-2gkh</link>
      <guid>https://forem.com/prakhil_tp/gitlab-ci-cd-a-guideline-to-set-up-your-pipeline-2gkh</guid>
      <description>&lt;p&gt;&lt;em&gt;This article is about making a successful CICD for your application using GitLab.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The modern development moves faster and demands more from developers than ever. Tools and concepts around CICD help developers deliver value faster and more transparently.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
You might have heard the term &lt;strong&gt;CICD&lt;/strong&gt; which is short for continuous integration (CI) and either continuous delivery or continuous deployment (CD). In a nutshell, CICD is an automated &lt;strong&gt;capability&lt;/strong&gt; and &lt;strong&gt;practice&lt;/strong&gt; aimed at enabling software developers to continuously deliver software from an environment to another with the help of a single command or push of a button.&lt;/p&gt;
&lt;h1&gt;
  
  
  &lt;strong&gt;Tl;dr&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Making a pipeline in GitLab is easy as pie, and everyone can do it. A remote machine and a GitLab repository are all needed for the setup. The coming sessions will guide you gently to set up your remote-machine and clarify the basics of YAML file configuration.&lt;/p&gt;

&lt;p&gt;   1. Requirements&lt;br&gt;
   2. Setting up a GitLab runner agent on the remote machine&lt;br&gt;
   3. Pipeline configuration&lt;br&gt;
   4. Continuous Integration&lt;br&gt;
   5. Continuous Delivery&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;1. Requirements&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Before we dive into the &lt;code&gt;CI/CD&lt;/code&gt; implementation, we should make sure the following are ready with us.&lt;/p&gt;

&lt;p&gt;    1. GitLab repository&lt;br&gt;
    2. Remote server&lt;/p&gt;

&lt;p&gt;Create a repository on GitLab and set up your project in it. We also need a &lt;strong&gt;remote machine&lt;/strong&gt; with &lt;code&gt;git&lt;/code&gt; installed on it. The remote instance can be used to run our pipeline scripts and also deploy our project.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;2. Setting up GitLab runner agent&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;GitLab Runner is a tool that we used to run our &lt;code&gt;jobs&lt;/code&gt; and send the results back to GitLab. It is designed to run on Linux, macOS, and Windows.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Install GitLab Runner
&lt;/h3&gt;

&lt;p&gt;Here is the &lt;a href="https://docs.gitlab.com/runner/" rel="noopener noreferrer"&gt;link&lt;/a&gt; to different &lt;code&gt;installation methods&lt;/code&gt;, you can choose one that fits for your remote machine.&lt;/p&gt;

&lt;p&gt;The binary installation method for &lt;code&gt;Linux x86-64&lt;/code&gt;, is what I'm showing here. Basically, just download the binary file to the &lt;code&gt;/usr/local/bin/&lt;/code&gt; directory and make it executable.&lt;/p&gt;

&lt;p&gt;Choose the &lt;a href="https://docs.gitlab.com/runner/install/linux-manually.html#using-binary-file" rel="noopener noreferrer"&gt;binary fle&lt;/a&gt; according to the system architecture. Type &lt;code&gt;arch&lt;/code&gt; on your terminal to know the system architecture.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download the binary
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Linux x86-64&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Give permission to execute
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo chmod&lt;/span&gt; +x /usr/local/bin/gitlab-runner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Create GitLab CI user
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;useradd &lt;span class="nt"&gt;--comment&lt;/span&gt; &lt;span class="s1"&gt;'GitLab Runner'&lt;/span&gt; &lt;span class="nt"&gt;--create-home&lt;/span&gt; gitlab-runner &lt;span class="nt"&gt;--shell&lt;/span&gt; /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Install and run as service
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;gitlab-runner &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gitlab-runner &lt;span class="nt"&gt;--working-directory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/gitlab-runner
  &lt;span class="nb"&gt;sudo &lt;/span&gt;gitlab-runner start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt; &lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Register the Runner
&lt;/h3&gt;

&lt;p&gt;There are three types of runners:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://docs.gitlab.com/ee/ci/runners/#shared-runners" rel="noopener noreferrer"&gt;Shared &lt;/a&gt;(for all projects)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.gitlab.co/ee/ci/runners/#group-runners" rel="noopener noreferrer"&gt;Group &lt;/a&gt;(for all projects in a group)&lt;/li&gt;
&lt;li&gt;Specific (for specific projects)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;We're going to set up a specific runner here. So that make sure you have the ownership of the project. Alright, let's go through the following steps to register our runner.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Goto to the project's &lt;strong&gt;settings &amp;gt;  CI/CD&lt;/strong&gt; and expand the &lt;strong&gt;Runner&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Click on the "Disable shared Runners" button If it's enabled.&lt;/li&gt;
&lt;li&gt;Note the registration token.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure you have got the registration token, then we're ready to register our GitLab Runner.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the following command.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;gitlab-runner register
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;The command will prompt you a few questions for the registration&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter coordinator URL (&lt;a href="https://gitlab.com/" rel="noopener noreferrer"&gt;https://gitlab.com/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Enter the token you got.&lt;/li&gt;
&lt;li&gt;Enter a description for this runner.&lt;/li&gt;
&lt;li&gt;Enter the tags for the runner. (Leave it empty if you're not using multiple runners for the project.)&lt;/li&gt;
&lt;li&gt;Select the &lt;a href="https://docs.gitlab.com/runner/executors/README.html" rel="noopener noreferrer"&gt;runner executer&lt;/a&gt; (eg: &lt;code&gt;shell&lt;/code&gt; )&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;We have one more step to do, is permitting root privileges to the GitLab Runner. It is not necessary If you're not going to use any permission needed (&lt;code&gt;sudo&lt;/code&gt;) commands in your ci/cd job&lt;/p&gt;

&lt;p&gt;Add the following line to the end of the &lt;code&gt;/etc/sudoers&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gitlab-runner ALL=(ALL) NOPASSWD:ALL

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All set, now we're ready to move on to the pipeline configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. Pipeline configuration&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We need the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file in the root of the repository, which defines the structure and order of pipelines and determines what to execute using &lt;code&gt;GitLab Runner&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's dive into the fundamentals of the YAML file.&lt;/p&gt;

&lt;h3&gt;
  
  
  jobs
&lt;/h3&gt;

&lt;p&gt;It is the most fundamental element of the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; file. As its name suggests, here is we write our scripts. Jobs are picked by &lt;code&gt;runners&lt;/code&gt; and executed within the environment of the runner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;job 1&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;execute&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;script&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;for&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;job1"&lt;/span&gt;

  &lt;span class="na"&gt;job 2&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;execute&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;script&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;for&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;job2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  stages
&lt;/h3&gt;

&lt;p&gt;It helps to define different &lt;code&gt;stages&lt;/code&gt; in the pipeline. The definition order will be the final execution order of the jobs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  stage
&lt;/h3&gt;

&lt;p&gt;It relies on &lt;code&gt;stages&lt;/code&gt; and allows to group &lt;code&gt;jobs&lt;/code&gt; into different stages. The &lt;code&gt;jobs&lt;/code&gt; of the same &lt;code&gt;stage&lt;/code&gt; are executed in parallel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

  &lt;span class="na"&gt;job 0&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.pre&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;make something useful before build stage&lt;/span&gt;

  &lt;span class="na"&gt;job 1&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;make build dependencies&lt;/span&gt;

  &lt;span class="na"&gt;job 2&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;make build artifacts&lt;/span&gt;

  &lt;span class="na"&gt;job 3&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;make test&lt;/span&gt;

  &lt;span class="na"&gt;job 4&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;make deploy&lt;/span&gt;

  &lt;span class="na"&gt;job 5&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.post&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;make something useful at the end of the pipeline&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;.pre&lt;/code&gt; and &lt;code&gt;.post&lt;/code&gt; stages are available to every pipeline. User-defined stages are executed after &lt;code&gt;.pre&lt;/code&gt; and before &lt;code&gt;.post&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are also two edge cases worth mentioning:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If no &lt;code&gt;stages&lt;/code&gt; are defined in &lt;code&gt;.gitlab-ci.yml&lt;/code&gt;, then the &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;test&lt;/code&gt;, and &lt;code&gt;deploy&lt;/code&gt; are allowed to be as the job's stage by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a job does not specify a &lt;code&gt;stage&lt;/code&gt;, the job will automatically be assigned to the &lt;code&gt;test&lt;/code&gt; stage.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;4. Continuous Integration&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You can set up a set of scripts to build and test your application on every code push that could save your application from sudden surprises.&lt;/p&gt;

&lt;p&gt;Let's do a simple CI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;

&lt;span class="na"&gt;Test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "write your test here."&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test -f "index.html"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above job will check the &lt;code&gt;index.html&lt;/code&gt; file exists or not. If it does not exist, the job will fail. Here the CI runs on every code push to the repository, Although we haven't given any control to the job &lt;code&gt;Test&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Alright, Let's move on to the delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;5. Continuous Delivery&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Continuous delivery is a development practice where code changes automatically prepared for a release to production. It is an extension of continuous integration to make sure that you can release new changes to your customers quickly in a sustainable way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

&lt;span class="na"&gt;Test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;echo "write your test here."&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test -f "index.html"&lt;/span&gt;

&lt;span class="na"&gt;Deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;refs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;sudo cp -R ./index.html /var/www/html/&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you see a &lt;code&gt;Deploy&lt;/code&gt; job with the &lt;code&gt;only&lt;/code&gt; keyword, which lets the job trigger only on the &lt;code&gt;master&lt;/code&gt; branch actions. &lt;/p&gt;

&lt;p&gt;Whenever you come across any job failing, you'll be able to see the logs on the console. It will help you move forward.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here we are! We took an extra step in our tech journey. In modern software development, CICD is an essential factor to be considered. So that I'm hoping this guideline makes sense to everyone.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;&lt;/p&gt;




&lt;p&gt; &lt;br&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“ Releasing software is too often an art; it should be an engineering discipline. ” -- David Farley&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>cicd</category>
      <category>devops</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>React Native CLI and Android Studio: Setting up the development environment on Linux</title>
      <dc:creator>Prakhil Thottipully</dc:creator>
      <pubDate>Sat, 15 Aug 2020 22:45:19 +0000</pubDate>
      <link>https://forem.com/prakhil_tp/react-native-cli-and-android-studio-setting-up-the-development-environment-on-linux-4jp6</link>
      <guid>https://forem.com/prakhil_tp/react-native-cli-and-android-studio-setting-up-the-development-environment-on-linux-4jp6</guid>
      <description>&lt;p&gt;This guideline will cover the absolute basics of getting started with React Native and Android studio using standard procedure.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Tl;dr&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;You'll need Node, JDK, React Native CLI, Android Studio to get started on your project.&lt;/p&gt;

&lt;p&gt;  1. Install Android Studio and Emulator.&lt;br&gt;
     2. Install Java Development Kit (JDK).&lt;br&gt;
     3. Configure environment variables.&lt;br&gt;
     4. Install Nvm, Node, yarn, react-native.&lt;br&gt;
     5. Running a new react-native app in a virtual device.&lt;br&gt;
     6. Troubleshoot.&lt;/p&gt;

&lt;p&gt;These steps will show you how to install and configure tools for developing React native app on Linux. I've specifically used &lt;em&gt;&lt;code&gt;Fedora 32&lt;/code&gt;&lt;/em&gt; for testing things out, but you should be able to translate the commands to the Linux distribution you're using. &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;1. Install Android Studio&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Download and install the Android studio. Be sure to mark the following boxes while installing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Android Virtual Device&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Android SDK&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Android SDK Platform&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once it finishes, open the SDK manager. &lt;/p&gt;

&lt;p&gt;under the &lt;strong&gt;SDK Platforms&lt;/strong&gt; tab, select a platform and make sure the following boxes are in it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Android SDK Platform 29&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Intel x86 Atom_64 System Image&lt;/code&gt; or &lt;code&gt;Google APIs Intel x86 Atom System Image&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same way, take the &lt;strong&gt;SDK Tools&lt;/strong&gt; tab, make sure that the following are marked.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Android SDK Build-Tools&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;NDK (side by side)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Android Emulator&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Android SDK Platform-Tools&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;2. Install Java Development Kit (JDK)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The JDK enables your computer to understand and run java code. React Native requires at least version 8 of the java development kit. You may download and install OpenJDK.&lt;/p&gt;

&lt;p&gt;Run the following command to install OpenJDK in fedora.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    &lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;java-11-openjdk.x86_64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;3. Configure environment variables&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Updating environment variables is necessary for the React native to build apps with native tools.&lt;/p&gt;

&lt;p&gt;Open .bashrc file  &lt;code&gt;sudo vim ~/.bashrc&lt;/code&gt;&lt;br&gt;
Feel free to use any text editor that you're comfortable with.&lt;/p&gt;

&lt;p&gt;Add the following lines to your config file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-11.0.8.10-2.fc32.x86_64"
export ANDROID_HOME="$HOME/Android/Sdk"
export PATH="$PATH:$ANDROID_HOME/emulator"
export PATH="$PATH:$ANDROID_HOME/tools"
export PATH="$PATH:$ANDROID_HOME/tools/bin"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save it. Then run &lt;code&gt;source ~/.bashrc&lt;/code&gt; to make the changes get reflected.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;4. Install node and react-native CLI&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this section, we're going to install necessary packages that help the react-native CLI to work smoothly.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.1 Install nvm&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let's start with nvm, which allows us to manage different versions of the node.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To verify that nvm has been installed, do: &lt;code&gt;command -v nvm&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you don't have curl, then you need to install it first.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.2 Install node&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We will use the latest &lt;em&gt;node&lt;/em&gt; stable version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    nvm install stable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You might need to open a new terminal for the nvm path to be loaded.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.3 Install yarn&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;we will use &lt;em&gt;yarn&lt;/em&gt; to manage our &lt;em&gt;node&lt;/em&gt; packages. In Fedora, you can install &lt;em&gt;yarn&lt;/em&gt; via the RPM package repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; sudo dnf install yarn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: The above command only works for Fedora-based distributions. (check &lt;a href="https://classic.yarnpkg.com/en/docs/install/#debian-stable" rel="noopener noreferrer"&gt;yarn website&lt;/a&gt; for other distributions.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.4 Install React Native&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn global add react-native-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;5. Running your app on a virtual device&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Alright, let's initialize the project repository and create a virtual device to run the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5.1 Initialize new React native project&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;First, move to the folder where you want to create your project folder. Then follow the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;react-native init &amp;lt;project-title&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;5.2 Create Virtual Device&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Launch Android studio then select &lt;strong&gt;AVD Manager&lt;/strong&gt; from the configure menu. Then a window will show up.&lt;/p&gt;

&lt;p&gt;1. Click on the &lt;strong&gt;Create Virtual Device&lt;/strong&gt;&lt;br&gt;
2. Choose a device you wish to install. Ideally, you want to have ones that already have &lt;code&gt;Play Store&lt;/code&gt; included.&lt;br&gt;
3. Select system image with &lt;code&gt;API Level&lt;/code&gt; 27 or above (download it if needed).&lt;br&gt;
4. Click on &lt;strong&gt;Finish&lt;/strong&gt; to view the next screen, which lists the created emulators.&lt;br&gt;
5. Click the &lt;strong&gt;play&lt;/strong&gt; button to launch the emulator.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: This may fail if your OS /tmp folder has insufficient space, displaying an error saying “No space left on device”. In this scenario, just increase its size to 8gb with the following command:&lt;br&gt;
&lt;code&gt;sudo mount -o remount,size=8G,noatime /tmp&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;5.3 Run your app&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Finally, run your app on the emulator. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to your project directory&lt;/li&gt;
&lt;li&gt;Open up two different terminals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One for running the Metro Bundler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; react-native start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another one for install and launch your app on the device:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; react-native run-android
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! Your app should be running on your virtual device.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;6. Troubleshoot&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here we are going to look at the most common errors you may encounter while setting up the environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Task :app:compileDebugJavaWithJavac FAILED
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;message:&lt;/strong&gt; &lt;code&gt;Could not find tools.jar&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This error will encounter when the JDK is not present in your system, or the system doesn’t recognize your JDK installation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Verify the environment variable &lt;code&gt;JAVA_HOME&lt;/code&gt; path is pointing to the right directory if not then update the path. &lt;br&gt;
If it doesn't work for you, then &lt;em&gt;reinstall&lt;/em&gt; the JDK.&lt;/p&gt;
&lt;h3&gt;
  
  
   Task :app:installDebug FAILED 
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;message:&lt;/strong&gt; &lt;code&gt;No connected devices!&lt;/code&gt; &lt;em&gt;OR&lt;/em&gt; &lt;code&gt;Unknown failure: cmd: Can't find service: package&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This error will encounter If you haven't created any virtual devices, or the runtime cannot recognize your device.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Creating a virtual device will help you to cover up the "No device connected" error.&lt;br&gt;
For that, open up the &lt;em&gt;Android Studio -&amp;gt; AVD Manager -&amp;gt; Create Virtual Device&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If it doesn't help you, then try the below commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;adb devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will show the list of devices available with their &lt;em&gt;deviceID&lt;/em&gt;. Copy the deviceId and run our React Native app with the &lt;em&gt;deviceId&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;react-native run-android --deviceId &amp;lt;deviceId&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;example: react-native run-android --deviceId emulator-5554&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;That's it! We've gone through every step to get started with the React Native on the Linux environment. I hope you guys got a little glimpse of wisdom from this article. See you in the next one.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What all trouble you got while setting up the environment? Share in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>linux</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Cron Job made easy: A setup guide to cron</title>
      <dc:creator>Prakhil Thottipully</dc:creator>
      <pubDate>Wed, 22 Jul 2020 09:17:40 +0000</pubDate>
      <link>https://forem.com/prakhil_tp/cron-job-for-node-scripts-1fa6</link>
      <guid>https://forem.com/prakhil_tp/cron-job-for-node-scripts-1fa6</guid>
      <description>&lt;p&gt;You can use a cron job for any program which runs on Linux by using the following method.&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;Tl;dr&lt;/b&gt;&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; Create a &lt;code&gt;script.sh&lt;/code&gt; file perform any action.&lt;/li&gt;
&lt;li&gt; Make use of &lt;code&gt;crontab -e&lt;/code&gt; command to create the cron job.&lt;/li&gt;
&lt;li&gt; Set the job to run the script for the specified timings.&lt;/li&gt;
&lt;li&gt; We troubleshoot the job by looking at the logs.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Contents&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Commands to manage cron jobs.&lt;/li&gt;
&lt;li&gt;Cron syntax.&lt;/li&gt;
&lt;li&gt;Setting up the script.&lt;/li&gt;
&lt;li&gt;Troubleshoot.&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cron is a useful tool in Linux that most developers love because it lets you run automated commands at specific periods (minutes, hours, days, etc.).&lt;/p&gt;

&lt;p&gt;Cron jobs run in the background and its keep checking few files and directories (&lt;code&gt;/etc/crontab/&lt;/code&gt;, &lt;code&gt;/etc/cron.*/&lt;/code&gt; and &lt;code&gt;var/spool/cron&lt;/code&gt; ..etc). Cron files are not supported to be edit directly, and each user has a unique crontab. The &lt;code&gt;crontab&lt;/code&gt; stands for the cron table. It is the list of commands that you want to run on a regular schedule.&lt;/p&gt;

&lt;h3 id="commands"&gt; Commands &lt;/h3&gt;

&lt;p&gt;
The commands for creating and editing cron jobs are the same and simple. And what's even cooler is that you don't need to restart the cron after making changes to the existing one.&lt;br&gt; cool! right?
&lt;/p&gt;

&lt;p&gt;let's view our cron table entries before creating a new one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;crontab &lt;span class="nt"&gt;-l&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will list if it has any. Anyway, let's move on to the step to create a cron job.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;crontab &lt;span class="nt"&gt;-e&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing special, single parameter change to command!.&lt;br&gt;
The command may prompt you to select a text editor(nano, vim), go on with the comfortable one.&lt;/p&gt;

&lt;p&gt;Now, we have a crontab file opened on a text editor to write our entries.&lt;/p&gt;

&lt;h3 id="syntax"&gt; Cron syntax &lt;/h3&gt;

&lt;p&gt;Just as it is with any language, working with cron is a lot easier when you understand its syntax. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;MIN HOUR DOM MON DOW CMD&lt;/code&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Allowed Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MIN&lt;/td&gt;
&lt;td&gt;Minute field&lt;/td&gt;
&lt;td&gt;0 to 59&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HOUR&lt;/td&gt;
&lt;td&gt;Hour field&lt;/td&gt;
&lt;td&gt;0 to 23&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DOM&lt;/td&gt;
&lt;td&gt;Day of Month&lt;/td&gt;
&lt;td&gt;1-31&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MON&lt;/td&gt;
&lt;td&gt;Month field&lt;/td&gt;
&lt;td&gt;1-12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DOW&lt;/td&gt;
&lt;td&gt;Day Of Week&lt;/td&gt;
&lt;td&gt;0-6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CMD&lt;/td&gt;
&lt;td&gt;Command&lt;/td&gt;
&lt;td&gt;Any command to be executed.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That's not all. Cron uses 3 operator symbols which allow you to specify multiple values in a single field.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Asterisk (*) - specifies all possible values for a field.&lt;/li&gt;
&lt;li&gt;The comma (,) - specifies a list of values.&lt;/li&gt;
&lt;li&gt;Dash (-) - specifies a range of values.&lt;/li&gt;
&lt;li&gt;Separator (/) - specifies a step value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By looking at the syntax we can write our entries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 3 * * * /home/user/path/to/script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Meaning, Run &lt;code&gt;/home/user/path/to/script.sh&lt;/code&gt; at 3 am every day.&lt;br&gt;
You can adjust periods by changing the time parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*/30 * * * * /home/user/path/to/script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above one will run the script every 30 minutes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;30 * * * * /home/user/path/to/script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would run at 1:30,2:30,3:30.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0,30 * * * * /home/user/path/to/script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would run at 1:30,2:00,2:30,3:00,3:30.&lt;/p&gt;

&lt;p&gt;Write this entry on the text editor we're previously opened using&lt;br&gt;
 &lt;code&gt;crontab -e&lt;/code&gt; command. Before saving it we need to set up our script for this.&lt;/p&gt;

&lt;h3 id="script"&gt; Setting up the script &lt;/h3&gt;

&lt;p&gt;Cron doesn't support &lt;code&gt;relative path&lt;/code&gt;, therefore you've to write the &lt;code&gt;absolute path&lt;/code&gt; for everything that you are pointing.&lt;/p&gt;

&lt;p&gt;You can find the absolute paths of directories by simply typing &lt;code&gt;pwd&lt;/code&gt; on your terminal.&lt;/p&gt;

&lt;p&gt;Make sure your script has execute permission.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;That's it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Save it all to run the cron job for the specified time period.&lt;/p&gt;


&lt;h3 id="troubleshoot"&gt; &lt;strong&gt;Troubleshoot&lt;/strong&gt; 

&lt;/h3&gt;
&lt;p&gt;Cron jobs are commands that your service runs at a specified interval and, as such, can be difficult to troubleshoot.&lt;/p&gt;

&lt;p&gt;Although we can't directly troubleshoot, some of the common mistakes are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using a relative path. You must be sure to use only absolute paths inside that script.&lt;/li&gt;
&lt;li&gt;Permissions are too strict. Please be sure all scripts, files that are being used are set to executable. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;chmod +x &amp;lt;file name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can check the cron logs to make sure that the crontab is working correctly. The logs are default located in &lt;br&gt;
&lt;code&gt;/var/log/syslog&lt;/code&gt;. And running the following grep command will get you all cron logs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"CRON"&lt;/span&gt; /var/log/syslog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're not finding the syslog file in your system, Then try the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;journalctl | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"CRON"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h3 id="conclusion"&gt; &lt;strong&gt;Conclusion&lt;/strong&gt; 

&lt;/h3&gt;
&lt;p&gt;Let's go through the steps we've done. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Created a &lt;code&gt;script.sh&lt;/code&gt; file to perform the action.&lt;/li&gt;
&lt;li&gt; Add an entry to the cron table using &lt;code&gt;crontab -e&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt; The crontab entry should point to the script.sh file.&lt;/li&gt;
&lt;li&gt; We troubleshoot the job by looking at the logs&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>cron</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
