scheduled-tasks

Run a python script from with arguments (from argparse in python) from crontab

懵懂的女人 提交于 2020-07-20 05:49:26
问题 I have a python script which uses argparse and accepts a few arguments and run it from cron example: python test.py --a apple --b ball This needs to be scheduled from crontab .I can run it manually but cron fails to recognise the arguments .Please suggest solution. The cron job line looks like : * * * * * /pathtopython/python test.py --a apple --b ball > /tmp/abc.out 2>&1 回答1: crontest.py file code : import argparse parser = argparse.ArgumentParser() parser.add_argument('--a', help="First

Recurring (daily) messages to a specific channel by my Slack App

微笑、不失礼 提交于 2020-07-03 07:31:31
问题 I'm writing a slack app which provides some stats about a service by demand using slash commands. The command calls my web api, I calculate stuff and return a formatted JSON that slack parses as a message. I would like to do the same but automatically, every day, at midnight. What I could do is set up the scheduling in my own server and call a webhook, which would be fine except that I want my service to be simple, passive, stateless and just respond to requests. Is there a way to set up

Flask-SQLALchemy update record automatically after specific time

大城市里の小女人 提交于 2020-06-28 04:46:28
问题 I have a db models like this: class Payment(db.Model): id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id')) ticket_status = db.Column(db.Enum(TicketStatus, name='ticket_status', default=TicketStatus.UNUSED)) departure_time = db.Column(db.Date) I want to change the value from all ticket_status after datetime.utcnow() passed the date value from departure_time . I tried to code like this: class TicketStatus(enum.Enum): UNUSED = 'UNUSED' USED

How to change existing folder's icon via Command Line? (Windows 10)

偶尔善良 提交于 2020-06-23 11:02:48
问题 I have a folder on my desktop and 12 different icons. I want to create a scheduled task with Task Scheduler that runs as long as my PC is on and changes the icon of the folder every 15 minutes. I have done my research and I found this code: `attrib -h -r c:\test\desktop.ini echo [.ShellClassInfo] >C:\test\desktop.ini echo IconFile=%SystemRoot%\system32\shell32.dll>>C:\test\desktop.ini echo IconIndex=0 >>C:\test\desktop.ini attrib +h +r c:\test\desktop.ini attrib +r c:\test` However, I have no

How to change existing folder's icon via Command Line? (Windows 10)

丶灬走出姿态 提交于 2020-06-23 11:02:42
问题 I have a folder on my desktop and 12 different icons. I want to create a scheduled task with Task Scheduler that runs as long as my PC is on and changes the icon of the folder every 15 minutes. I have done my research and I found this code: `attrib -h -r c:\test\desktop.ini echo [.ShellClassInfo] >C:\test\desktop.ini echo IconFile=%SystemRoot%\system32\shell32.dll>>C:\test\desktop.ini echo IconIndex=0 >>C:\test\desktop.ini attrib +h +r c:\test\desktop.ini attrib +r c:\test` However, I have no

Powershell Scheduled Task At Startup Repeating

試著忘記壹切 提交于 2020-06-15 04:28:19
问题 I'm trying to create a Scheduled Task with the following Trigger: - Startup - Run every 5 minutes - Run indefinitely In the GUI I can do this easily by selecting: - Begin the task: at startup And in the Advanced tab: - Repeat task every: 5 minutes - For a duration of: indefinitely But I'm having trouble doing it with Powershell. My troubled code: $repeat = (New-TimeSpan -Minutes 5) $duration = ([timeSpan]::maxvalue) $trigger = New-ScheduledTaskTrigger -AtStartup -RepetitionInterval $repeat

Powershell Scheduled Task At Startup Repeating

故事扮演 提交于 2020-06-15 04:27:09
问题 I'm trying to create a Scheduled Task with the following Trigger: - Startup - Run every 5 minutes - Run indefinitely In the GUI I can do this easily by selecting: - Begin the task: at startup And in the Advanced tab: - Repeat task every: 5 minutes - For a duration of: indefinitely But I'm having trouble doing it with Powershell. My troubled code: $repeat = (New-TimeSpan -Minutes 5) $duration = ([timeSpan]::maxvalue) $trigger = New-ScheduledTaskTrigger -AtStartup -RepetitionInterval $repeat

Python return value from scheduled event

流过昼夜 提交于 2020-06-12 07:47:21
问题 I would like to get the value returned from a function called by a scheduled event. Below is a simple example of what I would like to do. import time import sched schedule = sched.scheduler(time.time, time.sleep) def ret_this(): return "This." def schedthis(): schedule.enter(2,1,ret_this, ()) schedule.run() ## <- print returned value here if __name__ == "__main__": schedthis() I have tried many things like: schedule.enter(2,1,print ret_this, ()) or even: schedule.enter(2,1,ret = ret_this, ())

Spring scheduled tasks not firing

风格不统一 提交于 2020-06-11 07:05:28
问题 I'm teaching myself Spring, currently on scheduled tasks, and the following code does not fire the scheduled task. I believe it has something to do with the way I'm setting up the Spring context but that's only a guess - I'm trying to learn Spring so please excuse the ridiculous while loop. Application.java: package hello; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class Application { public static void main(String[] args) throws Exception {

ScheduledExecutorService Java EE how to start it in web service (JBoss)? [duplicate]

。_饼干妹妹 提交于 2020-06-09 04:07:47
问题 This question already has answers here : How to run a background task in a servlet based web application? (5 answers) Closed 2 years ago . In Java SE I have a scheduled tasks waiting to be executed when I run main(). But in Java EE (JBoss webservice) the methods are run when there's a web request. Is there a way to start scheduling tasks once the application is deployed? I was looking to use ScheduledExecutorService. 回答1: Caveat: This Answer addresses the app servers such as Apache Tomcat and