标题: [文本处理] 求大佬帮忙把Liunx中sh代码转bat [打印本页]
作者: 来学习 时间: 2023-9-22 14:36 标题: 求大佬帮忙把Liunx中sh代码转bat
本帖最后由 来学习 于 2023-9-22 14:38 编辑
感谢大佬们帮忙转下- #!/bin/bash
- #chown -R www:www /data/www
- export JAVA_HOME=/usr/java/jdk1.8.0_92
- ulimit -SHn 65535
- ulimit -c unlimited
- if test `jps | grep -c "gamebase"` = 0
- then
- ntpdate us.pool.ntp.org >/dev/null 2>&1 &
- fi
-
- servperm=384
- servmaxperm=512
- servmem=4096
- servmemhalf=2048
- cd gamejar
- nohup $JAVA_HOME/bin/java -server -Duser.timezone=Asia/Shanghai -XX:ReservedCodeCacheSize=256m -XX:MaxDirectMemorySize=1024m -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dlog4j.rootpath=./ -Djava.security.policy=jstatd.all.policy -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.port=9602 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider -Xdebug -Xrunjdwp:transport=dt_socket,address=9502,server=y,suspend=n -Xms${servmem}m -Xmx${servmem}m -Xmn${servmemhalf}m -XX:PermSize=${servperm}m -XX:MaxPermSize=${servmaxperm}m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:+CMSScavengeBeforeRemark -verbose:gc -XX:+Print**ateStamps -XX:+Print**etails -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCApplicationStoppedTime -Xloggc:./logs/gcserver.log -XX:+AggressiveOpts -XX:-OmitStackTraceInFastThrow -jar ./gamebase.jar >/dev/null 2>&1 &
- i=10
- while [[ $i != 1 ]]
- do
- sleep 10
- check_port() {
- netstat -tlpn | grep "\b$1\b"
- }
- SERVER_PORT1=31055 #端口1
- if check_port ${SERVER_PORT1}
- then
- i=1
- else
- echo "`date +%Y-%m-%d" "%H":"%M":"%S` 正在启动,请稍后···"
- fi
- done
- if [ $i = 1 ];then
- echo "`date +%Y-%m-%d" "%H":"%M":"%S` 启动完成"
- else
- echo "`date +%Y-%m-%d" "%H":"%M":"%S` 启动失败,请联系技术人员"
- fi
- sleep 3
复制代码
作者: Batcher 时间: 2023-9-22 16:03
回复 1# 来学习
test-1.bat
请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/Koje4FufWxWBs7ioDy_LJA- @echo off
- setlocal enabledelayedexpansion
-
- REM 根据JDK版本和安装路径进行设置
- set "JAVA_HOME=C:\Program Files\java\jdk1.8.0_92"
-
- set "servperm=384"
- set "servmaxperm=512"
- set "servmem=4096"
- set "servmemhalf=2048"
-
- REM 根据gamejar路径进行设置
- cd /d "C:\Users\Admin\Desktop\gamejar"
-
- %JAVA_HOME%\bin\java -server -Duser.timezone=Asia/Shanghai -XX:ReservedCodeCacheSize=256m -XX:MaxDirectMemorySize=1024m -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dlog4j.rootpath=./ -Djava.security.policy=jstatd.all.policy -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.port=9602 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider -Xdebug -Xrunjdwp:transport=dt_socket,address=9502,server=y,suspend=n -Xms%servmem%m -Xmx%servmem%m -Xmn%servmemhalf%m -XX:PermSize=%servperm%m -XX:MaxPermSize=%servmaxperm%m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:+CMSScavengeBeforeRemark -verbose:gc -XX:+Print**ateStamps -XX:+Print**etails -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCApplicationStoppedTime -Xloggc:./logs/gcserver.log -XX:+AggressiveOpts -XX:-OmitStackTraceInFastThrow -jar ./gamebase.jar
-
- set "SERVER_PORT1=31055"
- set "StatNum=10"
-
- :CheckPort
- REM 根据实际情况调整这个值的大小
- set "MaxTry=5"
- for /l %%i in (1 1 %MaxTry%) do (
- timeout /nobreak /t 10 >nul
- netstat -an | findstr /c:":%SERVER_PORT1% " >nul
- if errorlevel 1 (
- echo !date! !time! 正在启动,请稍后···
- ) else (
- set "StatNum=1"
- goto :End
- )
- )
-
- :End
- if !StatNum! equ 1 (
- echo !date! !time! 启动完成
- ) else (
- echo !date! !time! 启动失败,请联系技术人员
- )
- endlocal
- pause
复制代码
作者: 来学习 时间: 2023-9-22 16:56
回复 2# Batcher
感谢大佬
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |