Need a Linux command that takes much time
Solution 1
sleep
takes up however much time you pass to it.
Solution 2
dd if=/dev/zero of=/dev/null
will run until your computer runs out of zeroes. :D
You can also make dd run for a finite amount of time, if you specify count
or specify different values for if
and/or of
.
Or, if you want to do something useful, try badblocks -nvs /dev/sda
, which will run a nondestructive read/write test on your first hard disk.
Solution 3
You could also simply repeat a command forever. For instance:
$ while true ; do date ; done
Solution 4
updatedb this updates the locate database, so this is actually useful to run.
Solution 5
well find can run for a long time especially if you want to do specific task. Here is one command:
find / -size 15c
This will seach for files that have exactly 15 characters (in file that is) and it will scan whole HDD for it. This can be slow but if you use state of art computer then you can use other commands that can run endlessly. We can use find command in a loop:
while true; do find / -size 15c; done
The bad side of this command is that you are using HDD for this and if you run it often it may shorten your HDD life (im not very much HW educated so search on google for more details).
My personal choice for this task would be creating a series of random characters (95 in his case) and print them using infinte loop with this command:
while true; do echo
head -c 95 /dev/urandom | tr -dc A-Z-0-9-a-z
; done
If you have slow pc then use sleep command to delay the output for 1s (in this case) and save up some cpu power:
while true; do echo
head -c 95 /dev/urandom | tr -dc A-Z-0-9-a-z
&& sleep 1; done
Related videos on Youtube
Ego_I
Updated on September 17, 2022Comments
-
Ego_I over 1 year
Don't ask why, but I would like to know a linux command, besides
la -laR
, since that could not take that long according to where you are in the folder structure, that takes much time to complete.-
David Z about 14 yearsIt actually depends on your requirements... do you need this command to be doing something non-trivial while it's running? For instance, are you looking for something that will access the hard drive for a certain amount of time? Or rearrange values in RAM, or transmit continuous network traffic for that time? Or do you just want something that will not return for a certain amount of time? (That's
sleep
) And what exactly do you mean by "much time"? Some specific amount of time, or indeterminate-but-longer-than-X-seconds, or what? -
Ignacio Vazquez-Abrams about 14 years@David: Didn't he tell you not to ask why? :P
-
David Z about 14 yearsYes, and I wasn't asking why he needs it, I was asking what exactly he needs. There's a difference.
-
rinogo about 5 years
sleep
was giving me strange results for some reason. Another option that I imagined up usesping
. e.g.ping -c10 8.8.8.8
-
-
UNK about 14 yearsCareful, if you do run out of 0s write speed will slow down, as your HDD tries desperately to find an area with the right 0 configuration. It's easily fixable, though, just use another PC to connect and overwrite /dev/zero with their /dev/zero.
-
joaquin about 14 yearsThat's a hard way of doing 'sleep 10'?
-
Dennis Williamson about 14 yearsYes, as I thought I indicated.
-
rob about 14 years@Phoshi: good point; I think that's what sysadmins refer to as "zero installation" or "zero maintenance."
-
LawrenceC over 12 yearsI've found that /dev/zero compresses beautifully, though.