<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Cron on Kenno&#39;s Open Note</title>
    <link>https://blog.khmersite.net/tags/cron/</link>
    <description>Recent content in Cron on Kenno&#39;s Open Note</description>
    <image>
      <title>Kenno&#39;s Open Note</title>
      <url>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- 0.154.0</generator>
    <language>en</language>
    <lastBuildDate>Tue, 03 Sep 2024 16:15:58 +1000</lastBuildDate>
    <atom:link href="https://blog.khmersite.net/tags/cron/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Replacing cron with systemd timer</title>
      <link>https://blog.khmersite.net/p/replacing-cron-with-systemd-timer/</link>
      <pubDate>Tue, 03 Sep 2024 16:15:58 +1000</pubDate>
      <guid>https://blog.khmersite.net/p/replacing-cron-with-systemd-timer/</guid>
      <description>&lt;p&gt;Well, I don&amp;rsquo;t currently really have a good reason to replace a working cron job with systemd-timer beside practicing it.&lt;/p&gt;
&lt;p&gt;The following is the existing cron task for &lt;code&gt;www-data&lt;/code&gt; user. I want to convert this cron to a systemd-timer:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ sudo crontab -l -u www-data

# m h  dom mon dow   command
*/5 * * * * php -f /var/www/nextcloud/cron.php
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The above output indicates that the command &lt;code&gt;php -f /var/www/nextcloud/cron.php&lt;/code&gt; is run at every 5th minute, of course by &lt;code&gt;www-data&lt;/code&gt; user.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Crontab Tip</title>
      <link>https://blog.khmersite.net/p/crontab-tip/</link>
      <pubDate>Sun, 13 Dec 2020 23:01:32 +1100</pubDate>
      <guid>https://blog.khmersite.net/p/crontab-tip/</guid>
      <description>&lt;p&gt;On Fedora based system, whenever I need help writing a cron task and confused which field is minute, hour, day,..etc, I usually check the &lt;strong&gt;/etc/crontab&lt;/strong&gt; file.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-console&#34; data-lang=&#34;console&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;❯ cat /etc/crontab 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;SHELL=/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;PATH=/sbin:/bin:/usr/sbin:/usr/bin
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;MAILTO=root
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# For details see man &lt;span style=&#34;color:#ae81ff&#34;&gt;4&lt;/span&gt; crontabs
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# Example of job definition:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# .---------------- minute &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; - 59&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# |  .------------- hour &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; - 23&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# |  |  .---------- day of month &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; - 31&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# |  |  |  .------- month &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; - 12&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; OR jan,feb,mar,apr ...
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# |  |  |  |  .---- day of week &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; - 6&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Sunday&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; or 7&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; OR sun,mon,tue,wed,thu,fri,sat
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# |  |  |  |  |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# *  *  *  *  * user-name  command to be executed
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Recently, I found an online cron scheduler editor - &lt;a href=&#34;https://crontab.guru/&#34;&gt;crontab.guru&lt;/a&gt;. It can be used to create a new task expression, or we can use it to verify the existing cron schedule expressions that we have.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to test cron</title>
      <link>https://blog.khmersite.net/p/how-to-test-cron/</link>
      <pubDate>Tue, 18 Feb 2014 14:33:22 +0000</pubDate>
      <guid>https://blog.khmersite.net/p/how-to-test-cron/</guid>
      <description>&lt;p&gt;So you drop a script in &lt;code&gt;/etc/cron.daily&lt;/code&gt;. How to check if that script does what it is expected to do without having to wait, in this case, a day?&lt;/p&gt;
&lt;p&gt;Here is how:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# run-parts -v /etc/cron.daily
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Reference:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://stackoverflow.com/questions/4984725/how-to-test-cron-job&#34;&gt;http://stackoverflow.com/questions/4984725/how-to-test-cron-job&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Install crontab on CentOS 6</title>
      <link>https://blog.khmersite.net/p/install-crontab-on-centos-6/</link>
      <pubDate>Mon, 27 May 2013 14:33:26 +0000</pubDate>
      <guid>https://blog.khmersite.net/p/install-crontab-on-centos-6/</guid>
      <description>&lt;p&gt;When you install CentOS 6 using minimal CD, a lot of packages aren’t installed by default; &lt;strong&gt;cron&lt;/strong&gt; included. To install it,&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# yum install cronie
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After the installation, you can verify that crond is running:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# chkconfig --list crond
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
  </channel>
</rss>
