AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[batch](server)

Martin Hope
Ilya Yevlampiev
Asked: 2023-09-26 04:08:36 +0800 CST

为什么我可以从一个位置进行通配符复制,但不能从另一个位置进行通配符复制?

  • 5

一份通配符批量副本适合我:

sudo cp /home/jenkins/dist/*.war /opt/tomcat/webapps/

但另一个类似的则不然:

sudo cp /opt/tomcat/webapps/*.war /home/jenkins/archive
cp: cannot stat '/opt/tomcat/webapps/*.war': No such file or directory

但实际上这两个文件夹都有这样的文件:

sudo ls -l /opt/tomcat/webapps/
total 330536
drwxr-x--- 5 tomcat paysoft      4096 Sep 26 02:12 ROOT
-r-x------ 1 tomcat tomcat  127981631 Sep 26 02:10 ROOT.war
drwxr-x--- 4 root   root         4096 Feb 26  2023 site-api
-r-x------ 1 tomcat tomcat  106277537 Sep 26 02:11 site-api.war
drwxr-x--- 4 tomcat paysoft      4096 Sep 26 02:11 web-api
-r-x------ 1 tomcat tomcat  104181448 Sep 26 02:11 web-api.war

和

sudo ls -l /home/jenkins/dist/
total 569312
-rw-r--r-- 1 jenkins jenkins 112948432 Aug  1  2022 money-transfer-web.jar
-rw-r--r-- 1 jenkins jenkins 127981631 Sep 26 02:03 ROOT.war
-rw-r--r-- 1 jenkins jenkins 106277537 Sep 26 02:03 site-api.war
-rw-r--r-- 1 jenkins jenkins 131561362 Sep 26 02:03 terminal-server.jar
-rw-r--r-- 1 jenkins jenkins 104181448 Sep 26 02:03 web-api.war

是什么原因?

PS 目录本身是:

sudo ls -l /home/jenkins/
total 8
drwxr-xr-x 2 root    root    4096 Jul 11 15:20 archive
drwxr-xr-x 2 jenkins jenkins 4096 Jun 30  2022 dist
batch
  • 1 个回答
  • 54 Views
Martin Hope
Gilberto Martins
Asked: 2021-11-23 11:52:28 +0800 CST

Windows 2019 .BAT 脚本中的奇怪行为

  • 1

我必须将备份从 Linux MariaDB 恢复到 Windows MariaDB,PowerBI 网关将在其中导入其数据。“mariabackup”是 MariaDB 的物理备份工具。但要恢复它,目标文件夹 ( %programfiles%\MariaDB 10.3\data\) 必须为空。

由于rmdir /S /Q "%programfiles%\MariaDB 10.3\data\将删除“数据”目录(我不想要的!!!),我一直在努力避免在以下脚本(uncompress.bat)中出现这种不需要的行为:

rem Uncompress the backup sent by the linux server
rem and imports it to MariaDB
rem Gilberto Martins - 19/11/2021

rem Uncompress the backup
rem The backup path is "mnt\external01\"
tar -xf c:\users\mariabkp\bkp.tgz -C c:\users\mariabkp\

rem Stop MariaDB
net stop mysql

rem Prepare the Backup for Restoration
"C:\Program Files\MariaDB 10.3\bin\mariabackup.exe" --prepare --target-dir="c:\users\mariabkp\mnt\external01\backup"\

rem Erase the Database files
del /q "C:\Program Files\MariaDB 10.3\data\*.*"
FOR /D %p IN ("c:\Program Files\MariaDB 10.3\data\*") DO rmdir "%p" /s /q

rem Import backup to MariaDB
"C:\Program Files\MariaDB 10.3\bin\mariabackup.exe" --move-back --target-dir="c:\users\mariabkp\mnt\external01\backup"\

rem Restore MariaDB conf file
copy "c:\Users\Administrator\my.ini" "c:\Program Files\MariaDB 10.3\data" /y

rem Start MariaDB
net start mysql

我工作得很好,直到我必须删除要恢复的文件,正如您在前面看到的那样:

Microsoft Windows [Version 10.0.17763.1935]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\Administrator>uncompress.bat

C:\Users\Administrator>rem Uncompress the backup sent by the linux server

C:\Users\Administrator>rem and imports it to MariaDB

C:\Users\Administrator>rem Gilberto Martins - 19/11/2021

C:\Users\Administrator>rem Uncompress the backup

C:\Users\Administrator>rem The backup path is "mnt\external01\backup"

C:\Users\Administrator>tar -xf c:\users\mariabkp\bkp.tgz -C c:\users\mariabkp\

C:\Users\Administrator>rem Stop MariaDB

C:\Users\Administrator>net stop mysql
The MySQL service is stopping.
The MySQL service was stopped successfully.


C:\Users\Administrator>rem Prepare the Backup for Restoration

C:\Users\Administrator>"C:\Program Files\MariaDB 10.3\bin\mariabackup.exe" --prepare --target-dir="c:\users\mariabkp\mnt\external01\backup"\
C:\Program Files\MariaDB 10.3\bin\mariabackup.exe based on MariaDB server 10.3.31-MariaDB Win64 (AMD64)
[00] 2021-11-22 16:26:29 cd to c:\users\mariabkp\mnt\external01\backup\
[00] 2021-11-22 16:26:29 open files limit requested 0, set to 0
[00] 2021-11-22 16:26:29 This target seems to be not prepared yet.
[00] 2021-11-22 16:26:29 mariabackup: using the following InnoDB configuration for recovery:
[00] 2021-11-22 16:26:29 innodb_data_home_dir = .
[00] 2021-11-22 16:26:29 innodb_data_file_path = ibdata1:12M:autoextend
[00] 2021-11-22 16:26:29 innodb_log_group_home_dir = .
[00] 2021-11-22 16:26:29 Starting InnoDB instance for recovery.
[00] 2021-11-22 16:26:29 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
2021-11-22 16:26:29 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2021-11-22 16:26:29 0 [Note] InnoDB: Uses event mutexes
2021-11-22 16:26:29 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-11-22 16:26:29 0 [Note] InnoDB: Number of pools: 1
2021-11-22 16:26:29 0 [Note] InnoDB: Using SSE2 crc32 instructions
2021-11-22 16:26:29 0 [Note] InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
2021-11-22 16:26:29 0 [Note] InnoDB: Completed initialization of buffer pool
2021-11-22 16:26:29 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=7032026737757
2021-11-22 16:26:29 0 [Note] InnoDB: Starting final batch to recover 68 pages from redo log.
[00] 2021-11-22 16:26:30 Last binlog file , position 0
[00] 2021-11-22 16:26:31 completed OK!

C:\Users\Administrator>rem Erase the Database files

C:\Users\Administrator>del /q "C:\Program Files\MariaDB 10.3\data\*.*"
\Program was unexpected at this time.

C:\Users\Administrator>FOR /D \Program Files\MariaDB 10.3\data\*") DO rmdir "p" /s /q

C:\Users\Administrator>

我的问题:

  1. 为什么\Program was unexpected at this time.当我尝试时出现消息del /q "C:\Program Files\MariaDB 10.3\data\*.*"

  2. 为什么原始指令FOR /D %p IN ("c:\Program Files\MariaDB 10.3\data\*") DO rmdir "%p" /s /q回显为FOR /D \Program Files\MariaDB 10.3\data\*") DO rmdir "p" /s /q?看起来(但我不确定)它可能与“%p”变量有关。

  3. 为什么剩下的指令(导入备份、恢复 my.ini 和启动 MariaDB)没有执行?

我不得不承认,我是 Windows 脚本的新手。而且我认为没有必要为一个脚本安装完整的 Python3!

更新:我试图在“准备备份以进行恢复”之前“擦除数据库文件”,但我得到了相同的结果,即它在“FOR”指令处停止。

windows scripting batch mariadb
  • 1 个回答
  • 64 Views
Martin Hope
wb6vpm
Asked: 2021-09-01 10:42:34 +0800 CST

寻找一种使用批处理文件替换目录树中非零大小文件的每个实例的方法

  • 0

我试图找出一种方法让批处理脚本覆盖特定目录及其子文件夹中非零字节文件的每个实例。我猜,因为我正在寻找一个非零文件,如果它找不到任何非零大小的文件,我可能会用转义符循环它?

例如,覆盖每个非零文件大小的 example.txt 实例:

D:\
\---SubFolder1
    |   example.txt <10 bytes>
    |
    \---Subfolder2
        |   example.txt <0 bytes>
        |
        \---Subsubfolder1
                example.txt <20 bytes>

在示例中,D:\Subfolder1\example.txt 和 D:\Subfolder2\Subsubfolder1\example.txt 将被覆盖,但 D:\Subfolder2\example.txt 不会更改。

感谢@NiKiZe 的所有帮助!

工作代码:

@ECHO 关闭

设置 DPATH=%~dp0

FOR /R "%DPATH%" %%F IN ( *** 见下文) 如果 %%~zFGTR NEQ 0 CALL :NonEmptyFile "%%~F"
GOTO :EOF

:NonEmptyFile
ECHO 得到非空文件: %1
呼叫:EOF

*** 替换为您要替换的文件名,确保在某处使用单个字符通配符(我在扩展名中使用了它 - 例如,如果我正在搜索 example.txt,我将 * 替换为 example.t ?t)

windows batch-file windows-command-prompt batch
  • 1 个回答
  • 176 Views
Martin Hope
DefToneR
Asked: 2020-10-17 09:12:51 +0800 CST

Windows Batch:命令 FOR /F 和令牌,我如何从令牌 X 到行尾的变量?

  • 0

好的,我这几天一直在为此苦苦挣扎。我有一个有点复杂的脚本,但最后我只需要设置一个从 Token 4 到行尾的变量。基本上我运行一个命令,输出的开头有一些我不需要的单词。但是对于简历,这就是我想要的:

set _EVer=Garbage Garbage Garbage This is an example
for /F "tokens=4*" %%G in ('echo "%_EVer%"') do set "_EVerC=%%G

我需要我得到“垃圾垃圾这是一个例子”的输出设置一个变量“这是一个例子”

我尝试了 tokens=4* 但只设置了第一个单词,没有别的。

欢迎任何意见:) 谢谢

windows batch windows-batch
  • 1 个回答
  • 989 Views
Martin Hope
DefToneR
Asked: 2020-09-24 12:01:07 +0800 CST

在 Batch 或 Powershell 上获取完整的 Windows 版本。(如 Windows Server 2016 上的“Microsoft Windows [版本 10.0.18363.900]”

  • 2

我有这个问题。批量使用命令“ver”我得到:Microsoft Windows [Version 10.0.18363.900]

我需要脚本的最后一个子构建版本 (900) 来确定 Windows 是否处于最新的补丁级别(或在检查主构建版本之后接近它)我的脚本在 Windows 10、Windows 2019 上运行完美但不在windows 2016,因为“ver”将打印:Microsoft Windows [版本 10.0.14393]

没有子构建版本。检查“ Winver”时将在GUI上打印:1607版(OS构建14393.3930)

那么,在 Windows 2016 中,我可以从批处理或 powershell 中获得“3930”吗?WMI、sysinfo 等不会显示。

谢谢!

powershell batch windows-server-2016
  • 1 个回答
  • 967 Views
Martin Hope
Abhijith Gururaj
Asked: 2020-08-18 05:01:12 +0800 CST

如何在 Windows cmd 中使用端口的特定进程的会话下获取所有进程

  • 3

我想列出并终止属于使用端口的特定进程的会话的所有进程。这应该通过一个接受端口号作为输入的 Windows 批处理命令来实现。

例如:假设一个进程 PA 当前正在侦听端口 8081。PA 在会话 S1 下运行。有进程 PB 和 PC 与 PA 属于同一会话。PB 和 PC 将在不同的端口上运行(它们运行在哪些端口上并不重要)

windows 命令/批处理文件应以 8081 作为输入并终止进程 PA、PB 和 PC。

这可能吗?感谢对此的一点帮助,因为我不太精通批处理命令/脚本。

我失败的尝试:

(for /F "tokens=2" %%i in (for /f "tokens=5" %a in ('netstat -aon ^| findstr 8081') do tasklist /NH /FI "PID eq %a") do taskkill /NH /FI "SESSIONNAME eq %%i")
windows powershell batch-file windows-command-prompt batch
  • 3 个回答
  • 1155 Views
Martin Hope
fgrieu
Asked: 2020-02-27 01:28:41 +0800 CST

语言中立递归获取

  • 1

在.batWindows 的 cmd.exe 文件中,递归获取文件夹内容的所有权

takeown /f foldername /r /d Y >nul: 2>&1

问题是,它仅在当前语言环境中Yes的单词以字母 开头时才有效Y。例如它在法语中失败,它使用Oui,因此需要O.

任何解决方法?

windows windows-command-prompt batch
  • 1 个回答
  • 87 Views
Martin Hope
Shlomi
Asked: 2017-06-13 03:56:42 +0800 CST

批处理文件检查cpu并输出到txt

  • 0

我正在尝试编写一个简单的批处理文件来每 30 秒检查一次计算机的 cpu 并以当前时间输出到 txt 文件。我希望每一行都像:

Line1: %time% %cpu%
Line2: %time% %cpu%

到目前为止,这是我想出的,没有用:

:loop

echo %TIME% > C:\test.txt

wmic cpu get loadpercentage > C:\test.txt

timeout 30

goto loop
batch
  • 1 个回答
  • 4440 Views
Martin Hope
Protostome
Asked: 2017-03-04 05:28:31 +0800 CST

在 AWS Batch 中通过一个请求提交多个作业

  • 1

我正在使用 aws cli,如果一项一项完成,作业提交需要很长时间。有没有办法在一个请求中一次提交多个作业?

batch amazon-web-services aws-cli
  • 1 个回答
  • 2373 Views
Martin Hope
Jeff Huang
Asked: 2017-02-02 21:59:29 +0800 CST

如何防止任务计划程序错误/失败

  • 0

研究中似乎有很多神话和错误,没有多少有用的物品被退回或可能已经过时

  1. “无论是否登录都运行”,根据许多帖子/结果说此功能存在错误并且批处理文件未正确启动。

似乎只要“程序/脚本”和“开始”配置正确,问题就不应该发生吗?

  1. 如何在何时收到通知
    • 任务未正确触发

      似乎唯一的方法是使用触发事件运行另一个任务,但是该通知任务是否有可能无法正常触发?

    • 批处理文件失败

      似乎唯一的方法是为每个批处理文件添加额外的错误检查?

如果您想分享任何其他提示/技巧,请大声说出来!

提前致谢!

scheduled-task task-scheduler batch
  • 1 个回答
  • 695 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve