run command after certain time in Linux

How to Run Command After Certain Time in Linux

Sometimes you may want to run a Linux command after a specific amount of time. You can easily do this using sleep command. In this article, we will learn how to run command after certain time in Linux.


How to Run Command After Certain Time in Linux

Here are the steps to run Linux command after a certain delay of time. You need to add sleep command followed by sleep interval, after the long running command. Here is the syntax for this.

long-command & sleep duration; do-this-after-sleep

In the above command, the long running command is followed by & and sleep command. This is followed by the command that you need to run after sleep is over.

Here is a command to run a command after 5 minutes.

first-command & sleep 300; second-command

In the above command, first-command will be running in background. But second-command will start only after 300 seconds, that is, 5 minutes.

If you don’t have two commands but just one command to run, you can directly call sleep command, followed by the command to be run after sleep. Here is an example to run a command after 300 seconds.

sleep 300 ;  command-to-be-run

In this article, we have learnt how to run command after certain time in Linux.

Also read:

Timeout Command in Linux
How to Set SSH Warning Message in SSH
How to Remove Specific Item from JS Array
Detect Mobile Device in JavaScript
How to Detect Click Outside Element in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *