Results 1 to 3 of 3
I am in need of assistance. I am rather new to linux and to bash scripting. I have some basic programing knowledge.
What primary function I would like to accomplish ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-19-2011 #1Just Joined!
- Join Date
- Jul 2011
- Posts
- 2
Bash Script to monitor screen
I am in need of assistance. I am rather new to linux and to bash scripting. I have some basic programing knowledge.
What primary function I would like to accomplish with the script that would monitor a screen, restart the screen if necessary.
The secondary function would be to shut down the screen once every day, download the file and restart it.
The three issues I have come across are 1) I do not know how to have the script look for the screen 2) have this happen within a consistent time frame, i.e. every 15min 3) have the script run as a daemon at startup.
Thank you in advance,
HalbergM
- 07-19-2011 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,664
What do you mean by "screen"? Is there a program running in a screen, maybe?
Also, what do you mean by "download the file"?
- 07-19-2011 #3Just Joined!
- Join Date
- Jul 2011
- Posts
- 2
yes, I am running a program as a screen. the program is a server client, the intent of downloading the file is to ensure that it is the most recent version, because the program lacks the ability to update itself. However I can get it to shut itself down by printing the word "stop" within the screen.
I believe I have the logic down, the coding and syntax is where I am at a loss.
this is the segmented logic that I have so far and I apologize if this got a bit confusing:
This is where the script will check to see if the screen is running, if it isn't it will run the script I wrote that will run the program under the screenCode:#variables required for the script SCREENNAME= #Name of the screen that is to be checked CHECKTIME= #Time interval between checks REFRESHTIME= #Time interval between screen shut down, download and restart LAUNCHSCRIPT= #Name of the script that is used to launch the screen CLIENT= #the webaddress for the file to be downloaded
This is the part that should stop the screen, download the server client and launch it againCode:#check to see if the SCREENNAME is active if [ $SCREENNAME=false ] then (run $LAUNCHSCRIPT)
I do believe that I have to use cronjobs to get the timing to work, and that is another place I am at a loss.Code:screen -x $SCREENNAME -X stuff "`printf "Stop \r" #this will tell the screen to shut itself down wget $CLIENT #this will download the server client file run $LAUNCHSCRIPT #this will restart the screen


Reply With Quote
