Linux学习 -->解决Ubuntu系统上 No command 'crond' found
前两天,准备在Ubuntu服务器上,定时执行Gitlab备份的命令,如下所示
编辑 vi /etc/crontab 文件,添加如下定时脚本
# edited by ouyang 2017-8-11 添加定时任务,每天凌晨两点,执行gitlab备份
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
然而发现,凌晨2点并没有执行备份操作。
然后我去执行crontab 命令时提示 No command ‘crond’ found 无法执行。
root@ubuntu4146:/data/gitlabData/backups# crond reload
No command 'crond' found, did you mean:
Command 'cron' from package 'cron' (main)
crond: command not found
1、安装 cron
执行如下命令
sudo apt-get install cron
命令运行如下:
root@ubuntu4146:/data/gitlabData/backups# sudo apt-get install cron
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
cron is already the newest version.
下列软件包是自动安装的并且现在不需要了:
lib32asan0 lib32atomic1 lib32gcc-4.8-dev lib32gcc1 lib32gomp1 lib32itm1
lib32quadmath0 lib32stdc++-4.8-dev lib32stdc++6 libbonobo2-common
libc6-dev-x32 libc6-x32 libgnome2-common libltdl-dev liborbit-2-0 libssl-dev
libssl-doc libstdc++-4.8-dev libx32asan0 libx32atomic1 libx32gcc-4.8-dev
libx32gcc1 libx32gomp1 libx32itm1 libx32quadmath0 libx32stdc++-4.8-dev
libx32stdc++6 pkg-php-tools shtool
Use 'apt-get autoremove' to remove them.
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 310 个软件包未被升级。
2、 检测你的service路径
执行命令 which service
root@ubuntu4146:/data/gitlabData/backups# which service
/usr/sbin/service
3、 执行相关 cron命令,带上路径 /usr/sbin/service
比如执行命令 sudo /usr/sbin/service cron start ,启动 cron 服务
root@ubuntu4146:/data/gitlabData/backups# sudo /usr/sbin/service cron start
start: Job is already running: cron
上面命令返回 Job is already running: cron 表示 cron命令早已经在运行中,
通常你可以通过执行命令 ps -ef | grep cron查看 cron命令是否正在运行
root@ubuntu4146:/data/gitlabData/backups# ps -ef | grep cron
root 1096 1 0 10:40 ? 00:00:00 cron
root 2155 62366 0 10:45 pts/1 00:00:00 grep --color=auto cron
执行命令 sudo /usr/sbin/service cron status , 查看crontab服务状态
root@ubuntu4146:/data/gitlabData/backups# sudo /usr/sbin/service cron status
cron start/running, process 1096
执行命令 sudo /usr/sbin/service cron reload 重新 cron 服务配置
root@ubuntu4146:/data/gitlabData/backups# sudo /usr/sbin/service cron reload
执行命令 sudo /usr/sbin/service cron restart , 重新启动 cron 服务
root@ubuntu4146:/data/gitlabData/backups# sudo /usr/sbin/service cron restart
cron stop/waiting
cron start/running, process 1096
执行命令 sudo /usr/sbin/service cron stop , 停止 cron 服务
root@ubuntu4146:/data/gitlabData/backups# sudo /usr/sbin/service cron stop
cron stop/waiting
4、实际应用
将上面的gitlab备份任务 重新修改下。
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
# edited by ouyang 2017-8-11 添加定时任务,每天凌晨两点,执行gitlab备份
0 2 * * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
#也可以按照如下所示的方法,定时执行 auto_backup.sh脚本,脚本内容就填写: /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
#0 2 * * * root /data/gitlabData/backups/auto_backup.sh -D 1
然后重启 cron服务,这样就会正常运行定时任务了。
root@ubuntu4146:~# sudo /usr/sbin/service cron reload
root@ubuntu4146:~# sudo /usr/sbin/service cron restart
cron stop/waiting
cron start/running, process 17738
相关链接地址
git学习——> Gitlab如何进行备份恢复与迁移?
http://blog.csdn.net/ouyang_peng/article/details/77070977
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng/article/details/77124597如果本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行打赏。
Linux学习 -->解决Ubuntu系统上 No command 'crond' found的更多相关文章
- SLAM+语音机器人DIY系列:(一)Linux基础——2.安装Linux发行版ubuntu系统
摘要 由于机器人SLAM.自动导航.语音交互这一系列算法都在机器人操作系统ROS中有很好的支持,所以后续的章节中都会使用ROS来组织构建代码:而ROS又是安装在Linux发行版ubuntu系统之上的, ...
- ASP.NET Core 发布至Linux生产环境 Ubuntu 系统
ASP.NET Core 发布至Linux生产环境 Ubuntu 系统,之前跟大家讲解了 dotnet publish 发布,而没有将整个系统串起来. 今天就跟大家综合的讲一下ASP.NET Core ...
- 解决Ubuntu系统中文乱码显示问题,终端打开文件及查看目录
解决Ubuntu系统中文乱码显示问题 [日期:2014-02-20] 来源:Linux社区 作者:njchenyi [字体:大 中 小] 我是先安装了Ubuntu 12.04 Server,然后 ...
- 64位的Ubuntu系统上使用汇编nasm和C语言
64位的Ubuntu系统上使用汇编nasm和C语言 $ nasm -f elf foo.asm -o foo.o$ gcc -c bar.c -o bar.o$ ld -s foo.o bar.o ...
- 在Linux(Centos7)系统上对进行Hadoop分布式配置以及运行Hadoop伪分布式实例
在Linux(Centos7)系统上对进行Hadoop分布式配置以及运行Hadoop伪分布式实例 ...
- Nginx: ubuntu系统上查找nginx.conf配置文件的路径
问题描述:在ubuntu系统上,找到nginx.conf文件的位置. 解决方法:在终端窗口中,输入命令:nginx -t 回显中就可以看到nginx.conf文件的路径了. 参考:https://bl ...
- Nginx: ubuntu系统上如何判断是否安装了Nginx?
问题描述:ubuntu系统上,如何查看是否安装了Nginx? 解决方法:输入命令行:ps -ef | grep nginx master process后面就是Nginx的安装目录. 延伸:1. 如何 ...
- 如何在一个ubuntu系统上搭建SVN版本控制工具
有话说,由于公司项目部署需要,将Windows工程迁移到Linux,通过调查确定使用Ubuntu的Linux操作系统.那么如何快速搭建和Windows一样快捷方便的开发环境就很重要了.本文讲述如何在一 ...
- 在64位Ubuntu系统上安装32位程序包
在64位Ubuntu系统上安装32位的程序包 $sudo apt-get install package_name:i386 例如: $sudo apt-get install openjdk-7-j ...
随机推荐
- rdesktop连接远程windows
$ info rdesktop //看一下帮助信息吧$rdesktop 192.168.1.1 //打开了一个8位色彩的,$rdesktop -a 16 192.168.1.1 //这个是16位色 ...
- HEVC 有损优化一
前期通过X86汇编和C的优化,HEVC 编码有了大幅的提升,目前320x240可以到4~5 fps 了.从现在开始无损优化先放放(还有很大的优化空间),开始做有损优化.做有损优化,我们设定的前提是ps ...
- 第四章 Spring.Net 如何管理您的类___对象、对象工厂和应用程序上下文
在前面一章我们介绍了依赖注入,控制反转的概念,以及自己动手搭建了一下Spring.Net的环境.通过这些操作,我们知道了Spring.Net 的核心是使用依赖注入或控制反转这种思想来管理业务对象,降低 ...
- 在(MRv1)中JobTracker工作方式
在 Hadoop MapReduce 中,JobTracker 具有两种不同的职责: 管理集群中的计算资源,这涉及到维护活动节点列表.可用和占用的 map 和 reduce slots 列表,以及依据 ...
- python远程登录服务器(paramiko模块安装和使用)
转自:http://www.jb51.net/article/46285.htm 一:简介 由paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器 ...
- XML 和 JSON 的使用场景
我们都知道 JSON 和 XML 设计的初衷里都包含一点是对人类友好, 所以两者在这方面属于竞争关系. 而在 UI 描述上, 我觉得 XML 是比 JSON 要优异很多. 我们先来看一组简单的数据排版 ...
- 上传控件CSS用图片代替
<style type="text/css"> a.btn {width: 120px;height: 42px;overflow: hidden;display: b ...
- Thinkphp 图形验证码无法显示
不显示验证码的代码: public function verify(){ $verify = new \Think\Verify(); $verify->entry(); } 修改为: publ ...
- 重装Delphi10.2的IDE必要设置
重装Delphi10.2的IDE必要设置: 1,Tools->Options Editor Options->Display 右侧的 Right margin: 设为200 这个设置是为右 ...
- Python subprocess shell 编程规范
使用subprocess通过shell调用另一个模块组件时,需要对返回的code进行判断.判断结果为执行失败时需要raise Exception,不然调用树过于复杂时,我们很难跟踪到异常发生的位置.s ...