Difference between revisions of "Windows/DOS"
m (→Kill processes by image name) |
(→Scheduled Task seems to do nothing. Runs but stops immediately) |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 6: | Line 6: | ||
</pre> | </pre> | ||
| + | ===How to force logoff a session on another server=== | ||
| + | '''Method 1 with the TSM GUI''' | ||
| + | * Launch Terminal Services Manager (in Administrative Tools) | ||
| + | * In the menu: Actions "Connect to Computer..." | ||
| + | * Enter name of server you want to get on to | ||
| + | * Right-click and logoff one of the displayed sessions | ||
| + | '''Method 2 with Command prompt''' | ||
| + | * Launch Windows (DOS) box | ||
| + | * Enter "query session /server:<servername>" | ||
| + | * Enter "logoff <ID> /server:<servername>" | ||
===Return the value of a function into a variable in DOS batch .bat file=== | ===Return the value of a function into a variable in DOS batch .bat file=== | ||
What an awful language! | What an awful language! | ||
| Line 14: | Line 24: | ||
@echo NLS_LANG has been set to %NLS_LANG% | @echo NLS_LANG has been set to %NLS_LANG% | ||
</pre> | </pre> | ||
| + | |||
===Create a Scheduled Task from the command line=== | ===Create a Scheduled Task from the command line=== | ||
This one is particularly interesting as I need to start a shell Cygwin shell script on a regular basis<br /> | This one is particularly interesting as I need to start a shell Cygwin shell script on a regular basis<br /> | ||
| Line 22: | Line 33: | ||
echo N|SCHTASKS /Create /SC MINUTE /MO 10 /TN dbamon_dblist /TR "c:\cygwin\bin\bash.exe -l -c /cygdrive/c/home/ibmtools/scripts/oracle/dbamon_dblist.ksh" /ST 09:00 /RU runasuser /RP runaspwd | echo N|SCHTASKS /Create /SC MINUTE /MO 10 /TN dbamon_dblist /TR "c:\cygwin\bin\bash.exe -l -c /cygdrive/c/home/ibmtools/scripts/oracle/dbamon_dblist.ksh" /ST 09:00 /RU runasuser /RP runaspwd | ||
</pre> | </pre> | ||
| + | ===Scheduled Task seems to do nothing. Runs but stops immediately=== | ||
| + | * Check task scheduler log | ||
| + | Advanced:View log ... | ||
| + | <pre> | ||
| + | "Backup_archivelog_perl_NETTP_auto.job" (perl) | ||
| + | Finished 1/9/2015 1:10:00 PM | ||
| + | Result: The task completed with an exit code of (80). | ||
| + | "dbamon_datapump.job" (bash.exe) | ||
| + | Finished 1/9/2015 1:10:23 PM | ||
| + | Result: The task completed with an exit code of (1). | ||
| + | </pre> | ||
| + | * Check error code given | ||
| + | <pre> | ||
| + | C:\ibmtools\scripts\oracle\perl>net helpmsg 80 | ||
| + | |||
| + | The file exists. | ||
| + | |||
| + | |||
| + | C:\ibmtools\scripts\oracle\perl>net helpmsg 1 | ||
| + | |||
| + | Incorrect function. | ||
| + | |||
| + | </pre> | ||
| + | Not very helpful on the part of Microsoft but the 80 error turned out to be a whole load of sqlplus.exe processes (100's) hanging around in the task manager<br /> | ||
| + | Killed them and jobs started running again. | ||
Latest revision as of 15:04, 9 January 2015
Contents
Kill processes by image name[edit]
Have a runaway process with hundreds or thousands of programs (eg: cmd.exe) all running and need to kill them all in one go?
taskkill /F /IM cmd.exe taskkill /F /IM bash.exe
How to force logoff a session on another server[edit]
Method 1 with the TSM GUI
- Launch Terminal Services Manager (in Administrative Tools)
- In the menu: Actions "Connect to Computer..."
- Enter name of server you want to get on to
- Right-click and logoff one of the displayed sessions
Method 2 with Command prompt
- Launch Windows (DOS) box
- Enter "query session /server:<servername>"
- Enter "logoff <ID> /server:<servername>"
Return the value of a function into a variable in DOS batch .bat file[edit]
What an awful language!
set NLS_LANG= @echo NLS_LANG has been cleared @FOR /F "usebackq delims=!" %%i IN (`sqlplus -s /nolog @set_NLS_LANG.sql`) DO @set NLS_LANG=%%i @echo NLS_LANG has been set to %NLS_LANG%
Create a Scheduled Task from the command line[edit]
This one is particularly interesting as I need to start a shell Cygwin shell script on a regular basis
As crontab is not implemented by default, I use the Windows Scheduler to start the jobs.
This one creates a task called dbamon_dblist tat runs a shell every 10 minutes starting at 9 am and going on for 24 hours (so, forever).
It is run a user different from the logged on user. The echo at the start is to answer N to the question "Task exists, do you want to replace it". For some reason that doesnt work too well :(
echo N|SCHTASKS /Create /SC MINUTE /MO 10 /TN dbamon_dblist /TR "c:\cygwin\bin\bash.exe -l -c /cygdrive/c/home/ibmtools/scripts/oracle/dbamon_dblist.ksh" /ST 09:00 /RU runasuser /RP runaspwd
Scheduled Task seems to do nothing. Runs but stops immediately[edit]
- Check task scheduler log
Advanced:View log ...
"Backup_archivelog_perl_NETTP_auto.job" (perl) Finished 1/9/2015 1:10:00 PM Result: The task completed with an exit code of (80). "dbamon_datapump.job" (bash.exe) Finished 1/9/2015 1:10:23 PM Result: The task completed with an exit code of (1).
- Check error code given
C:\ibmtools\scripts\oracle\perl>net helpmsg 80 The file exists. C:\ibmtools\scripts\oracle\perl>net helpmsg 1 Incorrect function.
Not very helpful on the part of Microsoft but the 80 error turned out to be a whole load of sqlplus.exe processes (100's) hanging around in the task manager
Killed them and jobs started running again.