crontab

How to start/stop a cronjob using PHP?

荒凉一梦 提交于 2019-11-28 19:20:50
问题 If I type crontab -l in the command-line I can see the following line: # * * * * * /usr/bin/php /home/user/every_minute_script.php To start this cronjob, I need to edit the file using crontab -e command, remove the comment character at the beginning of the line, save the edited file, and exit the editor. To stop this cronjob, the same steps, but adding the comment character at the beginning of the line. I want to achieve exactly the same effect using a PHP script , instead of manually editing

Cron Job - How to send an output file to an email

邮差的信 提交于 2019-11-28 19:14:41
I have this line in crontab: * * * * * /var/www/dir/sh/mysql_dumb.sh | mail -s "mysql_dump" example@mail.com (every minute only a sample) So, all works fine, but the email is empty. UPDATE: The output from mysql_dumb.sh is a *.sql file and they save the file in a directory. How can I send a copy (*.sql file) from this output -> mysql_dumb.sh to my email? mysql_dumb.sh: #!/bin/bash PATH=/usr/bin:/bin SHELL=/bin/bash /usr/bin/mysqldump -u USER -pPASS DATABASE > /var/www/dir/backup/backup_DB_`date +%d_%m_%Y`.sql Barmar If the script is reporting errors, they may be going to stderr , but you're

Set Interval in Node.js vs. Cron Job?

为君一笑 提交于 2019-11-28 19:09:57
I'm learning node.js and just set up an empty Linux Virtual Machine and installed node. I'm running a function constantly every minute var request = require('request') var minutes = 1, the_interval = minutes * 60 * 1000 setInterval(function() { // Run code }) }, the_interval); And considering adding some other functions based on current time. - (e.g. run function if dateTime = Sunday at noon) My question is are there any disadvantages to running a set up like this compared to a traditional cron job set up? Keep in mind I have to run this function in node every minute anyways. It depends on how

Significance of question mark in Java cron

…衆ロ難τιáo~ 提交于 2019-11-28 19:05:59
Source Wikipedia: Question mark (?) is used instead of '*' for leaving either day-of-month or day-of-week blank. The above statement is not making much sense to me. So if I write some cron as 0 0 0 ? * * then does it mean first of every month or it means it will execute daily? It is a bit confusing as Java crons start with seconds while other crons start with minute. I am not Cron expert But according www.cronmaker.com it is executed daily. Dan King According to the Quartz CronTrigger tutorial (Quartz is used by www.cronmaker.com, referenced above), the ? wildcard is only used in the day of

Scrapy crawler in Cron job

别等时光非礼了梦想. 提交于 2019-11-28 18:50:37
I want to execute my scrapy crawler from cron job . i create bash file getdata.sh where scrapy project is located with it's spiders #!/bin/bash cd /myfolder/crawlers/ scrapy crawl my_spider_name My crontab looks like this , I want to execute it in every 5 minute */5 * * * * sh /myfolder/crawlers/getdata.sh but it don't works , whats wrong , where is my error ? when I execute my bash file from terminal sh /myfolder/crawlers/getdata.sh it works fine I solved this problem including PATH into bash file #!/bin/bash cd /myfolder/crawlers/ PATH=$PATH:/usr/local/bin export PATH scrapy crawl my_spider

tomcat,nginx日志定时清理

佐手、 提交于 2019-11-28 18:18:16
1. Crontab定时任务    Crontab 基本语法   t1 t2 t3 t4 t5 program 其中 t1 是表示分钟,t2 表示小时,t3 表示一个月份中的第几日,t4 表示月份,t5 表示一个星期中的第几天。program 表示要执行的程序。 当 t1 为 * 时表示每分钟都要执行 program,t2 为 * 时表示每小时都要执行程序,其馀类推 当 t1 为 a-b 时表示从第 a 分钟到第 b 分钟这段时间内要执行,t2 为 a-b 时表示从第 a 到第 b 小时都要执行,其馀类推 当 t1 为 */n 时表示每 n 分钟个时间间隔执行一次,t2 为 */n 表示每 n 小时个时间间隔执行一次,其馀类推 当 t1 为 a, b, c,... 时表示第 a, b, c,... 分钟要执行,t2 为 a, b, c,... 时表示第 a, b, c...个小时要执行,其馀类推 2. Tomcat日志清理脚本   Tomcat日志随着项目运行时长越来越多,访问量大时很可能撑满硬盘。下面贴一个自用的Tomcat日志清理脚本。 1 #!/bin/sh 2 3 #日志文件所在目录 4 #path=/usr/local/tomcat/apache-tomcat-8.5.32/logs 5 path=/usr/local/tomcat/apache-tomcat-8.5

10,crontab定时任务

南楼画角 提交于 2019-11-28 18:17:13
1,crond定时任务是Linux系统支持可扩展的一种自动执行命令或者脚本的功能 1,yum provides crond(查看命令包源) 2,系统定时任务目录文件 crond.hourly ------------系统定时任务每小时运行这个目录文件 crond.daily -------------系统定时任务每天运行这个目录文件 crond.weekly -------------系统定时任务每周运行这个目录文件 crond.monthly -----------系统定时任务每月运行这个目录文件 cond.deny ----------------系统禁止某些用户使用定时任务 crontab -------------------定时任务配置文件 2. crontab -l 查看当前定时任务列表 crontab -e 编辑定时任务 /var/spool/cron/root root用户写的定时任务会在这个目录下自动生成root定时任务文件 /var/spool/cron/普通用户名 普通用户写的定时任务会在这个目录下自动生成普通用户名定时任务文件 systemctl status crond systemctl start/stop crond /var/log/cron 定时任务日志记录 3.vi/etc/crontab 全局生效 分 时 日 月 周 30 8

gpg encrypt file without keyboard interaction [closed]

Deadly 提交于 2019-11-28 17:08:35
I am running next command within a crontab to encrypt a file and I don't want a keyboard interaction echo "PASSPHRASE" | gpg --passphrase-fd 0 -r USER --encrypt FILENAME.TXT but I have this answer: gpg: C042XXXX: There is no assurance this key belongs to the named user pub 40XXX/C042XXXX 2012-01-11 Name LastName. (comment) <user@email.com> Primary key fingerprint: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX Subkey fingerprint: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX It is NOT certain that the key belongs to the person named in the user ID. If you *really* know what you are

How to run a cron job inside a docker container

若如初见. 提交于 2019-11-28 17:04:23
I tried to run a cron job inside a docker container but nothing works for me my container have only cron.daily and cron.weekly file crontab,cron.d,cron.hourly ... are absent in my container crontab -e also not working my container runs with /bin/bash Here is how I run one of my cron containers. Dockerfile: FROM alpine:3.3 ADD crontab.txt /crontab.txt ADD script.sh /script.sh COPY entry.sh /entry.sh RUN chmod 755 /script.sh /entry.sh RUN /usr/bin/crontab /crontab.txt CMD ["/entry.sh"] crontab.txt */30 * * * * /script.sh >> /var/log/script.log entry.sh #!/bin/sh # start cron /usr/sbin/crond -f

mysqldump & gzip commands to properly create a compressed file of a MySQL database using crontab

倖福魔咒の 提交于 2019-11-28 16:17:27
问题 I am having problems with getting a crontab to work. I want to automate a MySQL database backup. The setup: Debian GNU/Linux 7.3 (wheezy) MySQL Server version: 5.5.33-0+wheezy1(Debian) directories user, backup and backup2 have 755 permission The user names for MySQL db and Debian account are the same From the shell this command works mysqldump -u user -p[user_password] [database_name] | gzip > dumpfilename.sql.gz When I place this in a crontab using crontab -e * * /usr/bin/mysqldump -u user