crontab

Linux Crontab及使用salt进行管理

痴心易碎 提交于 2019-11-26 20:30:22
一、引言:   最近无意之间看到salt有一个cron的模块,今天就在这里介绍linux crontab以及通过salt的cron对crontab的管理。 二、Linux crontab的介绍:   crontab是用于设置周期性被执行的指令。该命令从标准输入设备读取指令,并将其存放在"crontab"文件中,以供之后读取和执行。crontab存储的指令被守护进程激活,crond常常在后台运行,每一分钟检查是否有预定的作业需要执行。 2.1、crond的启动与关闭: # 查看crond的状态 [root@A01-R07-I165-88 ~] # service crond status # 关闭crond [root@A01-R07-I165-88 ~] # service crond stop # 启动crond [root@A01-R07-I165-88 ~] # service crond start # 重启crond [root@A01-R07-I165-88 ~] # service crond restart # 重新加载crond [root@A01-R07-I165-88 ~] # service crond reload 2.2、全部配置文件   crontab在/etc目录下面存在cron.hourly,cron.daily,cron.weekly,cron

08、启动过程+at+crond+anacron

此生再无相见时 提交于 2019-11-26 19:38:18
-- [root@li ~]# 加电--BIOS (basic input output system)--以什么设备来启动--/dev/sda -- mbr -- grub.conf --vmlinux and initramfs -- init -- /etc/inittab -- /etc/fstab -- /etc/rc.sysinit -- ls /etc/rcx.d -- /etc/rc.local --登录 系统引导程序 grub (就是一个boot loader) Grand Unified Boot Loader [root@li ~]# rpm -qa |grep grub grub-0.97-13.5 [root@li ~]# rpm -qi grub-0.97-13.5 Summary : GRUB - the Grand Unified Boot Loader. Description : GRUB (Grand Unified Boot Loader) is an experimental boot loader capable of booting into most free operating systems - Linux, FreeBSD, NetBSD, GNU Mach, and others as well as most

How can you execute a Node.js script via a cron job?

隐身守侯 提交于 2019-11-26 19:06:14
问题 Quite simply, I have node script that I want to execute once a month. 30 6 1 * * node /home/steve/example/script.js But this doesn't work, presumably because of path or the shell the command is being ran under. I've tried the following means of executing node via cron (tested with -v): steve@atom:~$ node -v v0.4.2 steve@atom:~$ sh node -v sh: Can't open node steve@atom:~$ bash node -v /usr/local/bin/node: /usr/local/bin/node: cannot execute binary file steve@atom:~$ /usr/local/bin/node -v v0

Crontab的格式+例子

不问归期 提交于 2019-11-26 18:33:25
启动服务 #service crond start 或者 # /etc/init.d/crond start 格式: *   *  *  *  *  command 分 时 日 月 周 命令 第1列表示分钟1~ 59 (每分钟用*或者 */1表示,*/ 5 代表每5分钟) 第2列表示小时1~ 23 (0表示0点) 第3列表示日期1~ 31 第4列表示月份1~ 12 第5列标识号星期0~ 6 (0表示星期天) 第6列要运行的命令 http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/ Linux Crontab Format MIN HOUR DOM MON DOW CMD Table: Crontab Fields and Allowed Ranges (Linux Crontab Syntax) Field Description Allowed Value MIN Minute field 0 to 59 HOUR Hour field 0 to 23 DOM Day of Month 1-31 MON Month field 1-12 DOW Day Of Week 0-6 CMD Command Any command to be executed. 1. Scheduling a Job For

iOS push notification does not work when using crontab scheduler

孤人 提交于 2019-11-26 18:18:23
问题 I have implemented a sample push notification service for my App. Right now I test in a sandbox environment. I get notifications when I manually call the PHP script to push notifications through APN. When I write a scheduler using crontab to automate the delivery of notifications I dont get the notifications. The error I get as a mail is: PHP Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert

Django custom command and cron

与世无争的帅哥 提交于 2019-11-26 18:02:50
问题 I want my custom made Django command to be executed every minute. However it seems like python /path/to/project/myapp/manage.py mycommand doesn't seem to work while at the directory python manage.py mycommand works perfectly. How can I achieve this ? I use /etc/crontab with: ****** root python /path/to/project/myapp/manage.py mycommand 回答1: I think the problem is that cron is going to run your scripts in a "bare" environment, so your DJANGO_SETTINGS_MODULE is likely undefined. You may want to

How to set up a cron job to run an executable every hour?

自闭症网瘾萝莉.ら 提交于 2019-11-26 17:59:06
问题 I need to set up a cron job that runs an executable compiled using gcc once every hour. I logged in as root and typed crontab -e Then I entered the following and saved the file. 0 * * * * /path_to_executable However, the cron job does not work. I see that when I type /...path_to_executable I get a segmentation fault. I can only execute the executable from the folder it is located in. Is there a way I can solve this problem? 回答1: 0 * * * * cd folder_containing_exe && ./exe_name should work

Linux计划任务

孤人 提交于 2019-11-26 17:57:40
博文结构 什么是例行性工作调度 仅执行一次的工作调度 循环执行的例行性工作调度 可唤醒停机期间的工作任务 一.什么是例行性工作调度? (1)两种工作调度方式 一种是例行性的,就是每隔一定的周期要来办的事项 一种是突发性的,就是这次做完以后就没有的那一种 (2)Linux下面达到这俩个功能 at :at 是个可以处理仅执行一次就结束调度的指令,不过要执行 at 时, 必须要有 atd 这个服务 的支持才行。在 某些新版的 distributions 中,atd 可能默认并没有启动,那么 at 这个指令就会失效呢!不过我们的 CentOS 默认是启动的! crontab :crontab 这个指令所设置的工作将会循环的一直进行下去! 可循环的时间为分钟、小时、每周、每月或每年等。 crontab 除了可以使用指令执行外,亦可编辑 /etc/crontab 来支持。 至于让 crontab 可以生效的服务则是 crond 这个服务 (3)基本上 Linux 系统常见的例行性任务有 进行登陆文件的轮替 登录文件分析logwatch的任务(主动分析登录信息工具) 创建locate的数据库(通过已经存在的文件名数据库来进行系统上文件名的查询) Man page查询数据库的创建(对应man page的数据库) RPM软件登录文件的创建(由于软件的经常变更,系统自动追踪) 移除暂存盘

How to pass in password to pg_dump?

╄→гoц情女王★ 提交于 2019-11-26 17:53:33
问题 I'm trying to create a cronjob to back up my database every night before something catastrophic happens. It looks like this command should meet my needs: 0 3 * * * pg_dump dbname | gzip > ~/backup/db/$(date +%Y-%m-%d).psql.gz Except after running that, it expects me to type in a password. I can't do that if I run it from cron. How can I pass one in automatically? 回答1: Create a .pgpass file in the home directory of the account that pg_dump will run as. See Postgresql documentation libpq-pgpass

crontab计划运行shell脚本,调用ncl执行失败

好久不见. 提交于 2019-11-26 17:46:31
编写了bash脚本,调用ncl脚本绘图,在前台运行时候无误,但是加入crontab任务就是始终无法出图,并且无错误输出。 经过搜索,问题得到解决。是环境变量的问题。所有执行的命令,和文件都要指定完整的路径,此外,对于ncl程序,还要在bash脚本中添加NCARG_ROOT环境变量。 详细过程 最近使用crontab,计划执行bash脚本,但老是得不到正确结果,而且还没有错误信息。经过广泛百度之后发现,需要在bash脚本中的首行加入这一句,从而可以将crontab的执行细节输出到日志 set -x; exec 2 >/path/to/logfile 参考自 https://stackoverflow.com/questions/34289641/sh-file-not-running-on-cron-ubuntu 这样就可以将crontab的执行结果输出到文件了。接下来查看输出文件,查找具体可能的原因。 查看输出文件,可以发现结果有如下输出: warning:Unable to Get System Resource File Name? warning:Unable to load System Resource File (null) 再次搜索相关帖子,发现出错原因:没有设置 NCARG_ROOT 变量 https://www.ncl.ucar.edu/Support