cron

Django/Python How should this cronjob be executed

隐身守侯 提交于 2020-01-16 19:17:10
问题 I created a simple python script that allows me to update a chosen animal to be displayed on the sites frontpage. when I am in my ssh, I run it like this. cd /www/site/mydirectory python perform_daily_action.py How do I run this in my crontab as a cronjob. I tried to do 30 09 * * * cd /www/site/mydirectory;python perform_daily_action.py Although this does not seem to work. Suggestions? 回答1: Try use this instead 30 09 * * * python /www/site/mydirectory/perform_daily_action.py 回答2: The other

kubernetes cronjob

天涯浪子 提交于 2020-01-16 17:47:06
CronJob Cron Job 管理基于时间的 Job ,即: 在给定时间点只运行一次 周期性地在给定时间点运行 一个 CronJob 对象类似于 crontab (cron table)文件中的一行。它根据指定的预定计划周期性地运行一个 Job,格式可以参考 Cron 。 前提条件 当前使用的 Kubernetes 集群,版本 >= 1.8(对 CronJob)。对于先前版本的集群,版本 < 1.8,启动 API Server(参考 为集群开启或关闭 API 版本 获取更多信息)时,通过传递选项 --runtime-config=batch/v2alpha1=true 可以开启 batch/v2alpha1 API。 典型的用法如下所示: 在给定的时间点调度 Job 运行 创建周期性运行的 Job,例如:数据库备份、发送邮件。 CronJob Spec .spec.schedule :调度,必需字段,指定任务运行周期,格式同 Cron .spec.jobTemplate :Job 模板,必需字段,指定需要运行的任务,格式同 Job .spec.startingDeadlineSeconds :启动 Job 的期限(秒级别),该字段是可选的。如果因为任何原因而错过了被调度的时间,那么错过执行时间的 Job 将被认为是失败的。如果没有指定,则没有期限 .spec

SpringBoot:实现定时任务

☆樱花仙子☆ 提交于 2020-01-16 14:00:38
一、定时任务实现的几种方式: Timer 这是java自带的java.util.Timer类,这个类允许你调度一个java.util.TimerTask任务。使用这种方式可以让你的程序按照某一个频度执行,但不能在指定时间运行。一般用的较少。 ScheduledExecutorService 也jdk自带的一个类;是基于线程池设计的定时任务类,每个调度任务都会分配到线程池中的一个线程去执行,也就是说,任务是并发执行,互不影响。 Spring Task Spring3.0以后自带的task,可以将它看成一个轻量级的Quartz,而且使用起来比Quartz简单许多。 Quartz 这是一个功能比较强大的的调度器,可以让你的程序在指定时间执行,也可以按照某一个频度执行,配置起来稍显复杂。 二、基于SpringBoot的定时任务 使用SpringBoot 自带的定时任务,只需要添加相应的注解就可以实现 2.1 导入SpringBoot启动包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.1.RELEASE</version> </dependency> 2.2 启动类启用定时 在启动类上面加上

Running python script through crontab can't find imports

此生再无相见时 提交于 2020-01-16 12:35:32
问题 I'm trying to run a python script through crontab, but it can't import any of the libraries that it needs when it is run this way. When I run the scripts outside of crontab, there is no issue, and I know that I have these libraries installed. Do I need to specify a path to them or something? Many thanks crontab file: SHELL=/bin/bash MAILTO=jess.chambers@gmail.com PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local */1 * * * * cd ~/Downloads/guichets && python newRdvChecker.py -G1 -S0

GAE Microservices with dedicated Cron Jobs per microservice

安稳与你 提交于 2020-01-16 07:32:13
问题 Can different microservices in GAE, own dedicated cron jobs? Background We have written multiple services on GAE microservices application. One micronservice say Service1(default) [JAVA in GAE Standard environment] has 10 cron jobs, wheareas another microservice say, Service2 [Python in GAE Flexible environment] has 5 other cronjobs. When we deploy both the services, cron jobs get replaced with the latest service cron jobs. I know that Task Queue is shared resource in GAE Microservices and

Linux crontab for nth Satuday of the month

旧巷老猫 提交于 2020-01-16 03:28:07
问题 I like to run back up for all weekdays except Saturday. My crontab entry 30 16 * * 1,2,3,4,5 ./backup.sh This entry working fine. Also, I like to take back up on 1st, 3rd Saturday. If any 5th Sutarday available in a month then the back up should run. What will be the entry for crontab? I am guessing 30 16 1-7, 15-21, 29-31 * 6 ./backup.sh Am I right? 回答1: Am I right? No you are not correct. The crontab manual states: Note: The day of a command's execution can be specified in the following two

Cronjob every two weeks

自古美人都是妖i 提交于 2020-01-16 01:09:11
问题 I want to run a cronjob every two weeks on Sundays at midnight. This is what I've tried. 0 0 * * 0/2 /path/to/script Is this correct? Will it execute the next Sunday and then every two weeks? I cant test it on my server at this point.. Please help. Thanks. 回答1: AFAIK cron can't handle "every second week". Instead, you could run it every Sunday at midnight and modify the script exit early if it's not one of the Sundays you want it to run. If modification of the script is not possible, create a

Upload clocking script

谁说我不能喝 提交于 2020-01-15 11:45:06
问题 How can I make a script that, once a day, will upload a file via ftp to several different servers, then take note (in a log) of how much time the uploads took? Thanks to Rajax I have the cronjob set up to execute this so far as the script, let's say it's called ftpScript.sh: #!/bin/sh HOST='ftp.users.qwest.net' USER='MYUSERNAME' PASSWD='MYPASSWORD' FILE='filename.gif' ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD put $FILE quit END_SCRIPT exit 0 Where do I put this part? time

special cron expression: how to make an exception?

两盒软妹~` 提交于 2020-01-15 10:16:24
问题 I made a cron to execute a task every tuesday at 3:50 AM - except a tuesday which coincides with the first day of the month: 50 3 * * 2 MyCommand but I don't know how I can translate my exception into the cron syntax, any tips? 回答1: Can you put a conditional in your script? I would do that. And in your cron you can comment that it won't run on the first per your script directions As an example, in bash you can do this: #!/bin/bash dayofmonth=`date +"%d"` if [ $dayofmonth == "01" ]; then # do

Crontab cannot find AWS Credentials - linuxbox EC2

无人久伴 提交于 2020-01-15 10:08:43
问题 I've created a linux box that has a very simple make bucket command : was s3 mb s3://bucket running this from the prompt works fine. I've run AWS configure as both the user I'm logged in as and sudo. The details are definitely correct as the above wouldn't create the bucket. The error message I'm getting from cron is :make_bucket failed: s3://cronbucket/ Unable to locate credentials I've tried various things thus far with the crontab in trying to tell it where the credentials are, some of