How to run a script at a certain time on Linux?
Look at the following:
echo "ls -l" | at 07:00
This code line executes "ls -l" at a specific time. This is an example of executing something (a command in my example) at a specific time. "at" is the command you were really looking for. You can read the specifications here:
http://manpages.ubuntu.com/manpages/precise/en/man1/at.1posix.html
http://manpages.ubuntu.com/manpages/xenial/man1/at.1posix.html
Hope it helps!
How to execute a loop for every one hour in BASH?
Run an hourly cron job with the code to perform the checking.
17 * * * * grep -q "Build of target : PASS" main.txt && fuser -k main.txt
fuser -k
is just a simple way to kill whoever is writing to main.txt
on Linux; if you know the PID or are on another platform, there will be other ways to figure out which process exactly to kill.
How to execute the same loop for 1 hour in bash/ linux scripting?
Surely. Try:
#!/bin/bash
START=`date +%s`
while [ $(( $(date +%s) - 3600 )) -lt $START ]; do
....
done
date +%s
shows the current time in seconds since 1970. The loop computes the current date of an hour ago and checks if it exceeds the start time.
Command to execute a script later
Take a look at the man page for at
man at
There are lots of ways you can specify the time. You can do something like:
at -f my_script.sh 23:00
Run a command at a specific time
You could try this:
at 1843 <<_EOF_
php /run/this/script.php
_EOF_
edit if what you want to do is run Firefox, try this:
at 1843 <<_EOF_
DISPLAY=:0.0 /usr/bin/firefox
_EOF_
Related Topics
Newbie on Debian and Trying to Make Java 7 the Default Java Version Used
How to Do Versioning of Shared Library
Force Linux to Use Only Memory Over 4G
Cannot --Enable-Pcregrep-Libbz2 Because Bzlib.H Was Not Found
Where Is Open_Max Defined for Linux Systems
How to Send Sigint (Ctrl-C) to Current Remote Process Over Ssh (Without -T Option)
Any Way to Specify the Location of Profile Data
Vim: Access to System Clipboard via Ssh - Linux to Os X
Configuring Selinux Permissions on (Svs-V) Ipc Semaphores
How to "Expect" and "Send" After "Interact" Command
Must a Process Group Have a Running Leader Process
On Linux, How to Make Sure to Unlock a Mutex Which Was Locked in a Thread That Dies/Terminates