Score:3

How to run a command after a delay at login with .bashrc

pt flag

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?

Organic Marble avatar
us flag
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.
pLumo avatar
in flag
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](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)?
Score:6
mx flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.