2

I want to run a bash script every hour in my cloud desktop which can be done by following commands:

while true; do ./parseScript.sh; sleep 3600; done

minute hour day month day-of-week command-line-to-execute

But the problem is my cloud window will expire so I won't be able to kill it in future? Can anyone guide me on this, How to do that?

2 Answers2

10

On every modern linux distribution you have the cron utility. This tool allow you to schedule tasks regularly (or not).

To schedule your task, you have to launch crontaband then, inside the file presented (which is the list of your scheduled tasks), put something like this :

0 * * * * /absolute/path/to/your/parseScript.sh

This will launch every hour at 0 minute (so, at 0:00, 1:00, 2:00....) your script (give the absolute path of your script)

With very last versions of cron, you can even use something easier :

@hourly /absolute/path/to/your/parseScript.sh

Because new shortcuts have been implemented (@hourly, @daily, @weekly, @monthly...)

Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
0

this solution:

$watch --interval=3600 command

No sudoer user, no config, ideal for just use from time to time as a dirty solution.

Also, you can cancel that execution whenever you want

leonardo rey
  • 707
  • 7
  • 7
  • 2
    'watch' is good to refresh the display at a specific interval. Not to execute a command. If you switch tab on your terminal, then switch back to the 'watch' tab, it executes again whatever the interval – Begoodpy Jul 27 '20 at 09:14