Contents
How do I run a command at a specific time in Linux?
How to run a command with a time limit on Linux
- Open the terminal application.
- Run ping command have it abort after 30 seconds: timeout 30s ping www.cyberciti.biz.
- One can combine sleep and other shell commands: ping www.cyberciti.biz & sleep 30s; kill $!
How do I run a shell at startup?
There is more than one way to do this.
- Put the command in your crontab file. The crontab file in Linux is a daemon that performs user-edited tasks at specific times and events.
- Put a script containing the command in your /etc directory. Create a script such as “startup.sh” using your favorite text editor.
- Edit the /rc.
How do I run a Linux script after login?
- Create a script file, e.g. named my_file.sh , in the /etc/profile. d/ directory.
- Put #!/bin/bash as the first line.
- Write whatever command(s) you want to be executed immediately after logging in, e.g. pgrep udhcpd .
- Mark your file as executable: chmod +x /etc/profile.d/my_file.sh.
How to execute a command on user logon?
If neither of the above work, try adding the command to ~/.profile : This is the main initialization file for login shells and is also read by some graphical shells on login.
Do you have to run a command at login?
Please note that this will run not just for GUI and SSH logins, but for all logins (or at least all interactive logins), including when you log on in a virtual console. Not the answer you’re looking for? Browse other questions tagged command-line login startup scripts or ask your own question.
How to run a command at login Ubuntu?
In contrast, .profile is only run by interactive login shells. See man bash and man sh for more information. Please note that this will run not just for GUI and SSH logins, but for all logins (or at least all interactive logins), including when you log on in a virtual console.
How to execute a command on a Linux desktop?
In Linux desktop system, I want to execute a command when the user logs in. After reading some other posts, I tried to insert the command in ~/.bashrc but unsuccessfully. Moreover, the system uses a graphic interface for the user login, so the command should not be related to the start of a shell.