snipt

Ctrl+h for KB shortcuts

Bash

Showing crontab for all users on machine

for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
https://snipt.net/embed/7ff70500a805e0a249b9ed36914e720f/
https://snipt.net/raw/7ff70500a805e0a249b9ed36914e720f/
7ff70500a805e0a249b9ed36914e720f
bash
Bash
2
2016-09-26T04:14:36
True
False
False
Feb 07, 2016 at 04:16 AM
/api/public/snipt/144041/
showing-crontab-for-all-users-on-machine
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">for</span> user in <span class="k">$(</span>cut -f1 -d: /etc/passwd<span class="k">)</span><span class="p">;</span> <span class="k">do</span> <span class="nb">echo</span> <span class="nv">$user</span><span class="p">;</span> crontab -u <span class="nv">$user</span> -l<span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
cron

Text only

Cron Job: Delete "error_log" file every 5 minutes in cPanel

1
2
3
4
5
6
7
8
For cPanel:

*/5	*	*	*	*

echo > /home/cPanelAccountGoesHere/public_html/error_log >/dev/null 2>&1
echo > /home/cPanelAccountGoesHere/public_html/administrator/error_log >/dev/null 2>&1

Don't forget to replace cPanelAccountGoesHere with account username.
https://snipt.net/embed/2f0a5b54401066def379c365834d99e8/
https://snipt.net/raw/2f0a5b54401066def379c365834d99e8/
2f0a5b54401066def379c365834d99e8
text
Text only
8
2016-09-28T18:10:54
True
False
True
Nov 27, 2014 at 07:02 AM
/api/public/snipt/137400/
cron-job-delete-error_log-file-every-5-minutes-9eb7a54d
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>For cPanel: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>*/5 * * * * </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>echo &gt; /home/cPanelAccountGoesHere/public_html/error_log &gt;/dev/null 2&gt;&amp;1 </span><span id="L-6"><a name="L-6"></a>echo &gt; /home/cPanelAccountGoesHere/public_html/administrator/error_log &gt;/dev/null 2&gt;&amp;1 </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a>Don&#39;t forget to replace cPanelAccountGoesHere with account username. </span></pre></div> </td></tr></table>
cron

Bash

No email on cron - add to end of script in crontab -e

>/dev/null 2>&1
https://snipt.net/embed/b94effa88130d0d083e388d31b8381ca/
https://snipt.net/raw/b94effa88130d0d083e388d31b8381ca/
b94effa88130d0d083e388d31b8381ca
bash
Bash
2
2016-09-29T10:00:26
True
False
False
Oct 18, 2013 at 06:15 AM
/api/public/snipt/88470/
no-email-on-cron-add-to-end-of-script-in-crontab-e
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>&gt;/dev/null 2&gt;<span class="p">&amp;</span>1 </span></pre></div> </td></tr></table>
cron, linux

Bash

List crontab for all users

 for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
https://snipt.net/embed/12f87d1365482c20ab0e3695e01ee741/
https://snipt.net/raw/12f87d1365482c20ab0e3695e01ee741/
12f87d1365482c20ab0e3695e01ee741
bash
Bash
1
2016-09-25T07:54:05
True
False
False
Nov 28, 2012 at 09:08 PM
/api/public/snipt/50937/
list-crontab-for-all-users
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a> <span class="k">for</span> user in <span class="k">$(</span>cut -f1 -d: /etc/passwd<span class="k">)</span><span class="p">;</span> <span class="k">do</span> <span class="nb">echo</span> <span class="nv">$user</span><span class="p">;</span> crontab -u <span class="nv">$user</span> -l<span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
bash, cron, linux

PHP

Delete Cron

1
2
3
4
5
6
<?php
delete_action( 'my_task_hook', 'my_task_deactivate' );
// clean the scheduler
function my_task_deactivate() {
	wp_clear_scheduled_hook( 'my_task_hook' );
}
https://snipt.net/embed/9cfd9530184892b2c5f2ebaf6b93c7a6/
https://snipt.net/raw/9cfd9530184892b2c5f2ebaf6b93c7a6/
9cfd9530184892b2c5f2ebaf6b93c7a6
php
PHP
6
2016-09-25T07:54:12
True
False
False
/api/public/snipt/44996/
delete-cron
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">delete_action</span><span class="p">(</span> <span class="s1">&#39;my_task_hook&#39;</span><span class="p">,</span> <span class="s1">&#39;my_task_deactivate&#39;</span> <span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="c1">// clean the scheduler</span> </span><span id="L-4"><a name="L-4"></a><span class="k">function</span> <span class="nf">my_task_deactivate</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">wp_clear_scheduled_hook</span><span class="p">(</span> <span class="s1">&#39;my_task_hook&#39;</span> <span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
WordPress, cron
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.