cron
How to create a Java cron job [duplicate]
You can use TimerTask for Cronjobs. Main.java public class Main{ public static void main(String[] args){ Timer t = new Timer(); MyTask mTask = new MyTask(); // This task is scheduled to run every 10 seconds t.scheduleAtFixedRate(mTask, 0, 10000); } } MyTask.java class MyTask extends TimerTask{ public MyTask(){ //Some stuffs } @Override public void run() { … Read more
Parsing crontab-style lines
Perhaps the python package croniter suits your needs. Usage example: >>> import croniter >>> import datetime >>> now = datetime.datetime.now() >>> cron = croniter.croniter(’45 17 */2 * *’, now) >>> cron.get_next(datetime.datetime) datetime.datetime(2011, 9, 14, 17, 45) >>> cron.get_next(datetime.datetime) datetime.datetime(2011, 9, 16, 17, 45) >>> cron.get_next(datetime.datetime) datetime.datetime(2011, 9, 18, 17, 45)
ssh-agent and crontab — is there a good way to get these to meet?
In addition… If your key have a passhphrase, keychain will ask you once (valid until you reboot the machine or kill the ssh-agent). keychain is what you need! Just install it and add the follow code in your .bash_profile: keychain ~/.ssh/id_dsa So use the code below in your script to load the ssh-agent environment variables: … Read more
How do I schedule the Let’s Encrypt certbot to automatically renew my certificate in cron?
I recently (April 2018) installed and ran certbot (version 0.22.2) on an Ubuntu 16.04 server, and a renewal cron job was created automatically in /etc/cron.d/certbot. Here’s the cron job that was created: # /etc/cron.d/certbot: crontab entries for the certbot package # # Upstream recommends attempting renewal twice a day # # Eventually, this will be … Read more
How to create cron statement to run for multiple hours
You cannot, you can use either multiple values OR a range 0 1,2,3,4,5,6,7,8,10,11,12,13,14,15 * * * Source: Time tags are separated by spaces. Do not use spaces within a tag, this will confuse cron. All five tags must be present. They are a logical AND of each other. There is another space between the last … Read more
Cron with notify-send
I use i3 on Ubuntu 18.04. My way to solve this is: * * * * * XDG_RUNTIME_DIR=/run/user/$(id -u) notify-send Hey “this is dog!” Edit 2020: I still use it on Ubuntu 20.04.
Crontab not executing a Python script? [duplicate]
There are a lot of half answers across the internet so I thought I would capture this to save someone else some time. First, cronjob does a poor job of telling you where this is failing. I recommend sending stderr output to a log file like this: Crontab Command: # m h dom mon dow … Read more