Introduction
Read this page if you want to have the Agent up and running as soon as the system starts.
In Windows
Can be done it two ways
By using Scheduled Task
- Open Control Panel -> Scheduled Tasks and click Add Scheduled Task
- Fill the Task tab like this one:
Make sure you are using local user as you might have problems with domain users. - On the Schedule tab select "At System Startup"
- On the Settings tab is important to cleanup/uncheck underlined checkbox as by default it is checked to stop process after 72 Hours.
By creating a Windows service
The following steps describe how to start the ATS Agent as a service. They are written for Windows 2008 Server. For other versions there may be some differences.
Open CMD and execute the folloowing command:
<path>\INSTSRV.EXE 'My Service Name' <path>\SRVANY.EXE
For example:C:\Program Files (x86)\Windows Resource Kit\Tools\instsrv.exe ATSAgent C:\Program Files (x86)\Windows Resource Kit\Tools\Srvany.exe
You will get a message that service is successfully created.
- Open regedit and find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ATSAgent
- From the Edit menu, click Add Key. Type 'Parameters' for key name.
- From the Edit menu, click Add Value. Set Value name to 'Application'
- Right click Modify and set Value data to the path where your ATS agent.bat file is. For example: C:\ats\ats-agent\agent.bat
Specify the full java path in the agent.bat file:
:: the java executable @SET JAVA_EXEC=C:\PROGRA~2\Java\jdk1.7.0_17\jre\bin\java
You can also refer to the following Microsoft KB article for running a script as a service on Windows:
https://support.microsoft.com/en-us/help/137890/how-to-create-a-user-defined-service
Alternatives
NSSM - the Non-Sucking Service Manager
RunAsService
In Linux and other UNIX-based OSes
Create service using systemd unit file
Recent versions of all major Linux distributions (like RedHat, CentOS, Ubuntu, Mint, SUSE) use newer service manager called systemd. You may refer to these pages in order to create service for you.
- https://linuxconfig.org/how-to-create-systemd-service-unit-in-linux
- https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/chap-managing_services_with_systemd
Create service using init script
Older Linux/UNIX systems use init manager. Even some new ones have backward compatibility mode and support it too. Here are instructions how to create init service.
Create init script in /etc/init.d, eg. atsAgent with the absolute path to the agent.sh file:
/etc/init.d/atsAgent#!/bin/sh /ats/agent.sh $@
Do not use symbolic links (ln -s) to the agent.sh script. Currently the agent.sh script has a problem to locate the agent path for all *nix systems using links.
Set X privileges
chmod a+x /etc/init.d/atsAgent
You can test the script by running: /etc/init.d/atsAgent status|version
- Add the script for automatic startup
1-st define the correct run level. You can check the your current run level by executing runlevel command.
In short the run levels are separated in this way:Run Level
Generic
Fedora Core
Slackware
Debian
0
Halt
Halt
Halt
Halt
1
Single-user mode
Single-user mode
Single-user mode
Single-user mode
2
Basic multi-user mode (without networking)
User definable (Unused)
User definable - configured the same as runlevel 3
Multi-user mode
3
Full (text based) multi-user mode
Multi-user mode
Multi-user mode - default Slackware runlevel
4
Not used
Not used
X11 with KDM/GDM/XDM (session managers)
Multi-user mode
5
Full (GUI based) multi-user mode
Full multi-user mode (with an X-based login screen) - default runlevel
User definable - configured the same as runlevel 3
Multi-user mode
6
Reboot
Reboot
Reboot
Reboot
Now create a symbolic link to the init script in the /etc/rc<runlevel_number>.d/ (in SUSE Linux it is /etc/rc.d/rc<runlevel_number>.d/).
The link name must start with S (means that the script is called with "start" argument) followed by a two-digit number (startup order - from the lowest to the highest) and the script name.
For example if you want to add it in runlevel 2, type the following command:ln -s /etc/init.d/atsAgent /etc/rc2.d/S20atsAgent # in SUSE ln -s /etc/init.d/atsAgent /etc/rc.d/rc2.d/S20atsAgent
The other option is using sysv-rc-conf command. After creating the init script, run the sysv-rc-conf command and mark the desired runlevel (mark S option too).
Troubleshooting
If the service is not started check the nohup.out file in ATS Agent /logs folder. A message like "failed to run command `java': No such file or directory" means that the java binary is not in the PATH environment variable. Possible solution is to export the PATH and JAVA_HOME from the service script file (before calling agent.sh)
#!/bin/sh export PATH=${PATH}:/usr/java/jre/bin export JAVA_HOME=/usr/java/jre /ats/agent.sh $@
Back to parent page
Go to Table of Contents