1 Star 0 Fork 52

raingive / kasini3000

forked from chuanjiao10 / kasini3000 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
zkj_uninstall_k记饭店_linux主控机.ps1 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
#建议保存编码为:bom头 + utf8
if ($IsLinux -eq $True)
{
$username = /usr/bin/whoami
if ($username -ne 'root')
{
Write-Error '非管理员'
Exit 1
}
#卸载 k_crontab
$ubuntu = /usr/bin/cat /etc/*-release | grep ubuntu
if ( ($ubuntu -eq $null) -or ($ubuntu -eq '') )
{
$任务计划文件 = '/var/spool/cron/root'
}
else
{
$任务计划文件 = '/var/spool/cron/crontabs/root'
}
Copy-Item -LiteralPath $任务计划文件 -Destination '/var/spool/' -Force
$private:新名字 = 'kaisini3000-' + (Get-Date -Format 'yyyy-MM-dd-HH:mm:ss')
Rename-Item -LiteralPath '/var/spool/root' -NewName $private:新名字
Write-Warning '已经备份任务计划文件,到/var/spool/'
$所有任务计划 = /usr/bin/crontab -l
if ($所有任务计划 -match 'u_db_crontab')
{
$crontab = Get-Content -LiteralPath $任务计划文件
$crontab2 = @()
foreach ($行 in $crontab)
{
if ($行.contains('u_db_crontab') )
{
}
else
{
$crontab2 += $行
}
}
Set-Content -LiteralPath $任务计划文件 -Value $crontab2 -Encoding UTF8nobom
chmod 600 $任务计划文件
systemctl restart cron
systemctl restart crond
}
else
{
Write-Error 'kasini3000,任务计划已经卸载!'
}
}
Write-Host -ForegroundColor green 'kasini3000,卸载完成!'
exit 0
PowerShell
1
https://gitee.com/raingive/kasini3000.git
git@gitee.com:raingive/kasini3000.git
raingive
kasini3000
kasini3000
master

搜索帮助