1 Star 0 Fork 51

sunguilou / project_10215868

forked from chuanjiao10 / kasini3000 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
u库定时任务_建立任务计划_linux.ps1 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
#建议保存编码为:bom头 + utf8
#Requires -RunAsAdministrator
#此脚本只能在主控机上运行。
& '/etc/kasini3000/0k_source.ps1'
if ($IsLinux -eq $True)
{
$username = /usr/bin/whoami
if ($username -ne 'root')
{
Write-Error '非管理员'
Exit 1
}
if ([System.Environment]::Is64BitOperatingSystem -eq $True)
{
}
else
{
Write-Error '不支持32位操作系统!'
Exit 2
}
$判断centos6 = @'
rpm -q centos-release
'@ | /usr/bin/bash
if ( $判断centos6.contains('el6'.tolower()) )
{
Write-Error '不支持centos6'
Exit 3
}
if (Test-Path '/etc/kasini3000')
{
}
else
{
Write-Error '找不到 /etc/kasini3000'
Exit 4
}
#安装sqlite
Copy-Item -LiteralPath '/etc/kasini3000/cmdb/linux.SQLite.Interop.dll' -Destination '/etc/kasini3000/cmdb/SQLite.Interop.dll' -Force
#安装 k_crontab
Copy-Item -LiteralPath '/var/spool/cron/root' -Destination '/var/spool/' -Force
$所有任务计划 = /usr/bin/crontab -l
if ($所有任务计划 -match 'u_db_crontab')
{
Write-Warning '任务计划已经安装!'
}
else
{
$卡死你_crontab_cmd = '* * * * * /usr/bin/pwsh -file /etc/kasini3000/u_db_crontab.ps1 > /dev/null 2>&1'
Add-Content -LiteralPath '/var/spool/cron/root' -Value $卡死你_crontab_cmd -Encoding UTF8nobom
}
#在/usr/bin创建快捷方式。
chmod u+x /etc/kasini3000/kc.sh
ln -s /etc/kasini3000/kc.sh /usr/bin/kc
chmod u+x /etc/kasini3000/kcp.sh
ln -s /etc/kasini3000/kcp.sh /usr/bin/kcp
}
exit 0
PowerShell
1
https://gitee.com/sunguilou/kasini3000.git
git@gitee.com:sunguilou/kasini3000.git
sunguilou
kasini3000
project_10215868
master

搜索帮助