• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to schedule a job using crontab

  • 00:36 lsb_release-a
  • 01:12 Crontab -e
  • 03:03 cd /root
{{postValue.id}}

To schedule a job using crontab

Introduction

Cron is used to scheduling commands; it is a standard Unix utility. It helps to maintain the software environment and also known as job crons. Crons is a long-running process to schedule work at a fixed time and date. It is connected to the server to complete the task automatically and also a resourceful tool that helps to save time.

Installation Procedure

Checking the installed OS version

linuxhelp@linuxhelp:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

Log in as a Root user by the following command

linuxhelp@linuxhelp:~$ sudo -s
[sudo] password for linuxhelp:

Editing the crontab file by the following command

root@linuxhelp:/home/linuxhelp# crontab -e
no crontab for root - using an empty one

Select an editor.  To change later, run 'select-editor'.
  1. /bin/nano      <---- easiest
  2. /usr/bin/vim.tiny
  3. /bin/ed

Choose 1-3 [1]: 

On Ubuntu based system it will ask for the editor for the first time to choose one or by default it uses the nano editor. Opened the Crontab file

Snap 1

Add the following lines, this will execute

10 14 * * * touch file
11 14 * * * mkdir folder
12 14 * * * cp file file1

Cron job scheduled Snap 2

Changing directory by using following command

root@linuxhelp:/home/linuxhelp# cd /root/

Long listing the home directory to view the files created by crontab

root@linuxhelp:~# ls -la
total 40
drwx------  6 root root 4096 Oct  6 13:54 .
drwxr-xr-x 20 root root 4096 Sep  8 16:50 ..
-rw-------  1 root root  627 Oct  6 13:47 .bash_history
-rw-r--r--  1 root root 3106 Aug 15  2019 .bashrc
drwx------  2 root root 4096 Apr 20 16:20 .cache
-rw-r--r--  1 root root    0 Oct  6 13:52 file
-rw-r--r--  1 root root    0 Oct  6 13:54 file1
drwxr-xr-x  2 root root 4096 Oct  6 13:53 folder
drwxr-xr-x  3 root root 4096 Oct  6 13:48 .local
-rw-r--r--  1 root root  161 Sep 16  2020 .profile
-rw-r--r--  1 root root   66 Oct  6 13:48 .selected_editor
drwxr-xr-x  3 root root 4096 Sep  8 17:00 snap

Snap3

By this schedule a job using crontab comes to end

Tags:
john
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is cron used for?

A

Cron is used to scheduling commands for an automatic course of action at specific intervals.

Q

How does a cron job work?

A

Cron Jobs are providing automate commands or scripts on your server to complete repetitive tasks spontaneously.

Q

What is cron job schedule?

A

Cron jobs schedule is recurring intervals, specifically used by Unix-cron format.

Q

How do I list all cron jobs?

A

In Ubuntu or debian, you can view crontab by /var/spool/cron/crontabs/

Q

How to Remove a crontab File

A

Remove the crontab file. $ crontab -r [ username ] where username specifies the name of the user's account for that you want to remove a crontab file.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Jayce ?
What are the types of table used in IPtables

What are the various types of table used in IPtables and how to use that for my server security?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.