I'm trying to run a command line on .bashrc after 20 seconds so I'm doing

sleep 20 && cp text1.txt text2.txt

But the system will not start until the 20 seconds go by, and then it will start. Is there anyway the system can start and then execute after 20 seconds the command script?

  • 1
    Do you want a command to run 20 seconds after you log in? It may be simpler to just use the "autostart" feature of whatever desktop you are using. Nov 28, 2021 at 17:57
  • 9
    What is your initial problem? Why do you need to cp a txt file to another, what do you wait 20 seconds for ? Is this an XY-Problem?
    – pLumo
    Nov 28, 2021 at 18:02

1 Answer 1


Run the command in the background using "&"

sleep 20 && cp text1.txt text2.txt &

The shell job ID (surrounded with brackets) and process ID will be printed on the terminal:

[1] 25177

To suppress the stdout and stderr messages use the following syntax:

sleep 20 && cp text1.txt text2.txt > /dev/null 2>&1 &

> /dev/null 2>&1 means redirect stdout to /dev/null and stderr to stdout

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.