Does anyone have a simple but effective script which can be used with If I simply tell the program itself to run on cron, I may get several copies running simultaneously. This program is not smart enough to test whether or not it is already active before firing up another copy of itself. asked 11 Nov '11, 18:35 ryans ♦♦ |
Yes. All you need to do is to create a simple bash script like this:
Then, run the program on a short cron job, like this:
In this example, I have named the script The script itself also uses the answered 11 Nov '11, 18:46 ryans ♦♦ Thanks, but I'm actually trying to keep an SSH tunnel alive for a database connection, and the:
line doesn't seem to work out-of-the-box for
(11 Nov '11, 18:48)
ryans ♦♦
The above is a general format applicable to all programs. Specifically for SSH, you should try something like this:
Where the following would be replaced by your information:
To be more aggressive in automatically handling migrations and/or IP changes by ignoring host credentials, add the Take a look at this community question for an example.
(11 Nov '11, 18:54)
ryans ♦♦
I'm new to Bash scripting, and have a problem with the watchdog script. My user name is replicounts, and the program that needs an occasional restart is aff.py. The crontab is working fine, and my watchdog.sh script (below) is being executed when it should. But the resulting watchdog.log is:
I manually run the program (in webapps/aff/htdocs) with:
The python3.1 is available interactively in all my directories. Also note:
FYI, my watchdog.sh script is:
What needs to be changed? John
(25 Apr '12, 14:03)
replicounts
cron doesn't operate with the same
Or, you can explicitly set the Hope that helps!
(25 Apr '12, 14:21)
seanf
Sorry but how can use this watchdog script with django and memcached? I think we need to restart django after starting memcached...
(02 Aug '13, 05:39)
sistineburak
The post directly above is a way to test your scripts in the cron environment. The first post in this answer explains how to create a monitor script. You would have to create the script and test it using the process above and than schedule it in cron, you would have to start memcached first, but that is something you will have to test and make work in the script with debugging.
(02 Aug '13, 21:12)
johns
I run this for supervisor but it keeps saying 'Already running.' any thought?
(28 Oct '13, 09:03)
jonyk
That means that supervisor (or another process with the same ID that you have in
(28 Oct '13, 11:09)
seanf
Good thinking; I think it is working now, I set the pidfile on supervisord to a folder and it runs perfectly. Thank you for your enlightment, Seanf!
(28 Oct '13, 20:29)
jonyk
Once you've got this all set up and running, how do you break the process if you make some change and want to restart it? I've got it working for my python script but I made a couple changes to the code and just want to restart it so those changes are in effect.
(14 Sep '14, 15:40)
arajendran
Hay men, how are you? How should be a script for maintain ever in on an elastichsearch server? Already are installed the server, and works, but, i can't be all time in the ssh connection for maintain the server on. Can anyone help me?
(24 Oct '14, 04:58)
Yusuf Salah ...
This command will show you your running processes:
Just kill the associated processes. The watchdog script should start them again, this time using the latest version.
(24 Oct '14, 05:29)
ryans ♦♦
@yusuf-salah-addin: Can you tell me how you normally start elasticsearch if it's not running? Which command do you use, and does it start the process in the foreground or in the background?
(24 Oct '14, 08:12)
ryans ♦♦
Ok, normally i have init the elasticsearch file in bin folder in elasticsearch folder because we can't use sudo for the server comand. '''./bin/elasticsearch This is the command, and i have put the completly file's path, and with this i init the server. You can see all here: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/running-elasticsearch.html i think do something like this: https://xenforo.com/community/threads/how-to-basic-elasticsearch-installation-debian-ubuntu.26163/, but, i haven't permissions for create the file. Thank you very much.
(24 Oct '14, 17:35)
Yusuf Salah ...
You would put the file in /home/YOU/bin or anywhere else in your home directory. You can't place files within the standard paths since it is a managed server, but you can place them within your home directory and configure them to run from there.
(24 Oct '14, 23:44)
johns
Yes, but, how? In my home is the elasticsearch folder, but, the rest, i don't know how do it; here more documentation: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-service.html
(27 Oct '14, 16:16)
Yusuf Salah ...
Just type:
That will give you the full path to the
(28 Oct '14, 01:29)
ryans ♦♦
an my script should have the same instructions as your script's example?
(08 Nov '14, 20:59)
Yusuf Salah ...
Yes, you can't run traditional services, so you have to create a watchdog script which does it, which should be mostly the same as the example above.
(08 Nov '14, 23:10)
johns
I'm new to crontab jobs, but have some processes I need to keep running and have a few questions about the script at the top of this thread.
Thanks!
(16 Nov '15, 16:44)
istarion
The script creates it.
The
(16 Nov '15, 20:24)
seanf
showing 5 of 21
show 16 more comments
|
For reference, here is cron's environment:
Additionally, cron runs the commands directly from your
And then run the command exactly as it appears in the crontab. answered 26 Apr '12, 00:53 ryans ♦♦ |