How to Set up a Crontab File on Linux

Method 1 of 2:

Setting up the File

  1. How to Set up a Crontab File on Linux Picture 1
    Using your favourite editor, create a cron file with a line for each job you wish to schedule, in the format: m h d m w command
    1. m minute
    2. h hour
    3. d day of month
    4. m month 1-12
    5. w weekday 0-7, Sun,Mon, etc (Sunday = 0 = 7) It is easy to remember if you think of the way one would say a date: Wednesday, July 29, at 10:30, then reverse the order.
  2. How to Set up a Crontab File on Linux Picture 2
    Load your file into crontab: crontab yourfile
Method 2 of 2:

Trying an Example

  1. Create a file testCron.txt containing the following lines:
    1. # do this every 10 minutes
    2. */10 * * * * date >> ~/testCron.log
  2. How to Set up a Crontab File on Linux Picture 3
    Load it into cron: crontab testCron.txt
  3. Wait 30 minutes, check testCron.log, if it works it will update your file with a time stamp 3 times.
  4. How to Set up a Crontab File on Linux Picture 4
    Remove the crontab so that it does not run forever: crontab -r
5 ★ | 1 Vote

May be interested

  • How to modify and manage Hosts files on LinuxHow to modify and manage Hosts files on Linux
    if you need to block web pages or create personalized web shortcuts on linux, solve these tasks by adding or adjusting a few lines in the hosts file.
  • 5 best applications to convert audio and video files on Linux5 best applications to convert audio and video files on Linux
    linux users are spoiled for choice when it comes to open source audio and video converters. here are the best media converters available today for linux, including a range of different file formats.
  • What are CBR and CBZ files? How to read CBR and CBZ files in LinuxWhat are CBR and CBZ files?  How to read CBR and CBZ files in Linux
    maybe while playing online, you've seen some cbr and cbz files. these are the two most popular formats for distributing comics and graphic novels online.
  • How to Create an ISO File in LinuxHow to Create an ISO File in Linux
    this wikihow teaches you how to turn a group of files into an iso file on a linux computer. you'll use the linux command line to do this. gather your iso files in the home directory. place any files that you want to turn into an iso file...
  • How to use wildcards to match file names in LinuxHow to use wildcards to match file names in Linux
    searching for files in linux can seem confusing at first, but don't worry, it gets easier once you understand wildcards. wildcards are special symbols that help you select multiple files or folders without having to type each name individually.
  • Micro editor in Unix / LinuxMicro editor in Unix / Linux
    there are many ways to edit files in unix and for me, one of the best ways is to use the editor to edit the micro screen orientation. this editor lets you edit the lines of content with other lines in the file.
  • Use Journalctl to read the system log on LinuxUse Journalctl to read the system log on Linux
    most linux-based operating systems have switched to systemd, which comes with a different daemon log called journald. to interact with these logs, use the journalctl utility.
  • How to Delete Read-Only Files on LinuxHow to Delete Read-Only Files on Linux
    there are several ways to help you delete files read-only on linux. if it's a file you own, you can change the file permissions or use the sudo command to delete the original file. however, if you cannot delete files with write permissions (or see a 'read only file system' error message), you need to change the drive with the appropriate permissions. this article will show you how to delete read-only files on any linux distribution, including ubuntu and linux mint.
  • The Cat command in LinuxThe Cat command in Linux
    the cat command (short for 'concatenate') is one of the most frequently used commands in operating systems like linux / unix. the cat command allows users to create one or more files, view file contents, join files, and redirect output in a terminal or file.
  • File Management in Unix / LinuxFile Management in Unix / Linux
    all data in unix is ​​organized in files. all files are organized in folders. these directories are organized in a tree structure that is called the file system.