• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

crontab Command Examples in Linux

by admin

The cron daemon is controlled using the crontab command. The command assumes the current user unless the -u option is specified. You can create, view, and delete crontab files using the crontab command.

Some of the options of the crontab command include:

Options Used To
-e Edit the crontab file for the current user.
-l View the crontab file for the current user.
-r Delete the current crontab file.
-u Create a crontab file on behalf of the specified user.

The syntax of the crontab command is:

# crontab [options] [file/ user]

crontab Command Examples

1. Edit the crontab file for the current user:

# crontab -e

2. Edit the crontab file for a specific user:

$ sudo crontab -e -u user

3. Replace the current crontab with the contents of the given file:

# crontab path/to/file

4. View a list of existing cron jobs for current user:

# crontab -l

5. Remove all cron jobs for the current user:

# crontab -r

6. Sample job which runs at 10:00 every day (* means any value):

0 10 * * * command_to_execute

7. Sample crontab entry, which runs a command every 10 minutes:

*/10 * * * * command_to_execute

8. Sample crontab entry, which runs a certain script at 02:30 every Friday:

30 2 * * Fri /absolute/path/to/script.sh

Filed Under: Linux

Some more articles you might also be interested in …

  1. How Files/Directories in /tmp gets Removed Automatically in CentOS/RHEL 5,6
  2. What is the refid in ntpq -p output?
  3. How to allow or deny telnet login to specific users only in CentOS/RHEL
  4. Basics of Ethernet Bonding in Linux
  5. How to Remove/Delete All Packages from Channel(s) in SpaceWalk
  6. Basic Linux File system tutorial – ext2, ext3, ext4, JFS and XFS
  7. What is the purpose of “system user” in MySQL Replication
  8. ntpq Command Examples in Linux
  9. How to uninstall neovim from Ubuntu
  10. ubuntu-drivers: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright