Board logo

标题: [文本处理] 求大佬帮忙把Liunx中sh代码转bat [打印本页]

作者: 来学习    时间: 2023-9-22 14:36     标题: 求大佬帮忙把Liunx中sh代码转bat

本帖最后由 来学习 于 2023-9-22 14:38 编辑

感谢大佬们帮忙转下
  1. #!/bin/bash
  2. #chown -R www:www /data/www
  3. export JAVA_HOME=/usr/java/jdk1.8.0_92
  4. ulimit -SHn 65535
  5. ulimit -c unlimited
  6. if test `jps | grep -c "gamebase"` = 0
  7. then
  8. ntpdate us.pool.ntp.org >/dev/null 2>&1  &
  9. fi
  10. servperm=384
  11. servmaxperm=512
  12. servmem=4096
  13. servmemhalf=2048
  14. cd gamejar
  15. 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  &
  16. i=10
  17. while [[ $i != 1 ]]
  18. do
  19. sleep 10
  20. check_port() {
  21. netstat -tlpn | grep "\b$1\b"
  22. }
  23. SERVER_PORT1=31055 #端口1
  24. if check_port ${SERVER_PORT1}
  25. then
  26.    i=1
  27. else
  28. echo "`date +%Y-%m-%d" "%H":"%M":"%S` 正在启动,请稍后···"
  29. fi
  30. done
  31. if [ $i = 1 ];then
  32. echo "`date +%Y-%m-%d" "%H":"%M":"%S` 启动完成"
  33. else  
  34. echo "`date +%Y-%m-%d" "%H":"%M":"%S` 启动失败,请联系技术人员"
  35. fi
  36. sleep 3
复制代码

作者: Batcher    时间: 2023-9-22 16:03

回复 1# 来学习


test-1.bat
请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/Koje4FufWxWBs7ioDy_LJA
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. REM 根据JDK版本和安装路径进行设置
  4. set "JAVA_HOME=C:\Program Files\java\jdk1.8.0_92"
  5. set "servperm=384"
  6. set "servmaxperm=512"
  7. set "servmem=4096"
  8. set "servmemhalf=2048"
  9. REM 根据gamejar路径进行设置
  10. cd /d "C:\Users\Admin\Desktop\gamejar"
  11. %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
  12. set "SERVER_PORT1=31055"
  13. set "StatNum=10"
  14. :CheckPort
  15. REM 根据实际情况调整这个值的大小
  16. set "MaxTry=5"
  17. for /l %%i in (1 1 %MaxTry%) do (
  18.     timeout /nobreak /t 10 >nul
  19.     netstat -an | findstr /c:":%SERVER_PORT1% " >nul
  20.     if errorlevel 1 (
  21.         echo !date! !time! 正在启动,请稍后···
  22.     ) else (
  23.         set "StatNum=1"
  24.         goto :End
  25.     )
  26. )
  27. :End
  28. if !StatNum! equ 1 (
  29.     echo !date! !time! 启动完成
  30. ) else (
  31.     echo !date! !time! 启动失败,请联系技术人员
  32. )
  33. endlocal
  34. pause
复制代码

作者: 来学习    时间: 2023-9-22 16:56

回复 2# Batcher


    感谢大佬




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2