How to run a command after a delay at login with .bashrc
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?
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