Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run command after 1 hour in Linux

Tags:

I just want to echo my string after 1 hour. I saw at command but it can run script at specific time (HH:MM). I want my echo command to run after 1 hour whatever the time it is.

like image 739
Muhammad Abdullah Avatar asked Nov 24 '15 19:11

Muhammad Abdullah


People also ask

How do I run a command after 5 minutes?

When you start up your computer press ctrl + alt + t and type amazon-sync then minimize the terminal window. Command will run once every 5 minutes (300 seconds).

How do I run a script every 5 minutes in Linux?

basic 3. /usr/bin/vim. tiny 4. /bin/ed Choose 1-4 [1]: Make a new line at the bottom of this file and insert the following code. Of course, replace our example script with the command or script you wish to execute, but keep the */5 * * * * part as that is what tells cron to execute our job every 5 minutes.


2 Answers

It is sleep 60m && ls

like image 165
01axel01christian Avatar answered Sep 20 '22 13:09

01axel01christian


According to the sleep man page, sleep will

Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time specified by the sum of their values.

So you can either use sleep 1h, sleep 60m or sleep 3600s or just sleep 3600 to sleep for 1 hour and then execute your command ls after that. For example sleep 1h && echo "hello world".

like image 44
jdhao Avatar answered Sep 17 '22 13:09

jdhao