How to execute a linux command repeatedly after a set time

0 votes

Is it possible in linux command line to have a command repeat every n seconds.

I want to execute  a command after say every 2 minutes. Say for example I have an import statement running and I'm doing:

ls -l

to check the file size is increasing. Is there someway I can do this automatically.

Jul 26, 2019 in Linux Administration by Damon Salvatore
• 5,980 points
323 views

1 answer to this question.

0 votes

To watch the step every say 30 seconds do:

watch -n 30 ls -l

In case you want this to print the differences add --differences flag before the ls command.

According to the OSX man page, there's also

The --cumulative option makes highlighting "sticky", presenting a running display of all positions that have ever changed. The -t or --no-title option turns off the header showing the interval, command, and current time at the top of the display, as well as the following blank line.

Linux/Unix man page can be found here

answered Jul 26, 2019 by ajs3033
• 7,280 points

Related Questions In Linux Administration

0 votes
1 answer

How to find Resident Set Size of a process in Linux?

Hi@akhtar, RSS is a memory currently used by ...READ MORE

answered Oct 12, 2020 in Linux Administration by MD
• 95,320 points
423 views
0 votes
1 answer

How to create nested directories with a single command in linux?

Try this command. mkdir -p /parent_dir/son_dir READ MORE

answered Oct 19, 2020 in Linux Administration by anonymous
• 19,620 points
586 views
0 votes
1 answer

How to create a symlink in Linux?

To create a symbolic link, you can ...READ MORE

answered Feb 1, 2019 in Linux Administration by Omkar
• 69,150 points
306 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 21, 2019 in Linux Administration by DareDev
• 6,890 points
313 views
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,230 points
390 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
323 views
0 votes
1 answer

Access progrs prompt without switching accounts

Use the following to get the postgres prompt ...READ MORE

answered Mar 22, 2019 in Database by Mahi
239 views
0 votes
2 answers

How do I use a shell script to SSH in to a remote machine to execute commands?

Sorry in advance for any formatting. Check out ...READ MORE

answered Feb 7 in Linux Administration by anonymous
12,102 views
0 votes
2 answers

how to loop through the content of a file using bash

#!/bin/bash for i in  `cat peptides.txt` do echo $i done READ MORE

answered Sep 5, 2020 in Linux Administration by Prakash K. Aithal
1,481 views