How can I schedule a program to run whenever after iis recycle? - iis

I need to run a program that warm up my app. Is there some way to schedule that whenever iis recycle?
I'm using IIS 7.5.

If you have a batchfile or exe that does the warming up you can schedule it as follows for a manual issreset
execute on ONE single line on a commandprompt:
schtasks /create
/tn warmup-app
/tr drive:\path\warmup.cmd
/sc ONEVENT
/EC System
/MO *[System/EventID=3201]
and if executed you're greeted with
SUCCESS: The scheduled task "warmup-app" has successfully been created.
Now configure IIS to log it's apppool restarts in the EventLog:

Related

run batch file at startup on windows start

Every morning when i restart Azure VM then i want to run batch file automatically.
This batch file is starting selenium grid. So what i did is added Task scheduler and created trigger to start script at Startup.
Then i tried to run the task manually but it doesnt do anything.
Although it may not be mandatory to paste code for batch file but still here it is
cmd /C start/MIN java -jar selenium-server-standalone-3.141.59.jar -role hub -port 4445
cmd /C start/MIN java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://localhost:4445/grid/register
I have windows server 2012. When i manually click batch file then it run but not working via startup script
You can add the batch file to system registry
to execute if any user log in: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
to execute if only current user log in: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
or
[HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Run]
[HKEY_CURRENT_USER\SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Run]

system cron not running intended process scheduled for execution

I have node server that I want to restart whenever it stopped. For this case I setup system cron on ubuntu server to execute a simple bash script that will track node server every minute and log the server status. Now this cron trigger this bash script and logs relevant status every minute but node server doesn't execute(Using simple linux command I can check if node server running or not). When manually running that bash script node server starts but something happening when cron executes that script. I am trying to fix this meanwhile any help will be appreciated.
Thanks
instead of doing this with cron i think you have to use spervisor in order to keep the process running check this supervisor website

How to trigger a custom script to run whenever a specific systemd service restarts

I wish to know how can I schedule a custom script to run whenever I restart a service.
My use case is that I have to run several commands whenever I restart my Tomcat Service. I want to know if there is a way I can write a script and schedule it to run whenever I restart the Tomcat service.
I have setup the tomcat script as a systemd service. I am using Cent OS 7 x64.
I have been able to achieve this by creating another service and incorporating the Tomcat service's start stop in the new service. The new service acts as a wrapper service which first starts tomcat and then executes the commands that we need to run as soon as tomcat starts.
Then while stopping, it stops tomcat and runs clean up commands.
EDIT: I found another way of doing this on unix & linux stackexchange.
Simply create an new systemd .service file in /etc which includes and overrides part of the one in /lib. For example, create /etc/systemd/system/tomcat.service to contain
.include /lib/systemd/system/tomcat.service
[Service]
ExecStartPre=/home/meuh/myscripttorun some pre args here
ExecStartPost=/home/meuh/myscripttorun some post args here
Any ExecStartPre lines will be executed before the ExecStart line, and similarly any ExecStartPost will run after tomcat has started.

PhantomJS Webserver exe on Azure Web Role Startup

I am trying to launch a local webserver instance of PhantomJs on a Azure Web (or Worker) Role to use with HighCharts for rendering server side charting images.
PhantomJs comes as just a simple .exe that can be launched as a webserver with the following command:
phantomjs highcharts-convert.js -host 127.0.0.1 -port 3003
... and then local HTTP POST requests can be made against it.
I have included this command in a startup.cmd batch script that is configured to execute with my Azure Web Role when published via ServiceDefinition.csdef:
<Startup>
<Task commandLine="startup.cmd" executionContext="elevated" taskType="background" />
</Startup>
startup.cmd:
START phantomjs highcharts-convert.js -host 127.0.0.1 -port 3003
EXIT /B 0
From what I can tell, this appears to execute fine on startup, however, the process does not stay running. It just executes and closes. For example, I can remote into the box, find the deployment and execute startup.cmd manually (in which a command window opens and stays open), and everything works fine.
How do I execute the PhantomJs exe webserver upon instance startup to where it continues running and does not close?
I have tried setting taskType to simple and background in the ServiceDefinition.csdef declaration, yet it doesn't seem to change anything.
It could be a timing issue if it is executing. You could add something like:
ping 1.1.1.1 -n 1 -w 300000 > nul
before you execute the script.
You could also pipe out to a log file so if its executing you can see what it is doing. >> log.txt.
If its not executing I would probably look at the path given its executing in the background and not interactively.
Turns out that I did not have the supporting .js files set to "Copy To Output Directory", so the startup.cmd could not find them.
Thanks to Steve for the output logging suggestion, which allowed me to see the error that it could not find "highcharts-convert.js".

How to set up a cron job for PHP on IIS?

How would I go about setting up a PHP cron job in IIS?
Cron jobs are usually not executed via http servers, so use the Task Scheduler to execute the php interpreter and provide the physical path to your php script as a commandline argument.

Resources