<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ali Aboosaidi &#187; cron</title>
	<atom:link href="http://insanelabs.com/tag/cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://insanelabs.com</link>
	<description>Umm... Unorthodox?</description>
	<lastBuildDate>Tue, 08 Nov 2011 21:04:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Linux: Crontab notes for different users &#8211; run a cron job every time a system reboots</title>
		<link>http://insanelabs.com/linux/linux-crontab-notes-for-different-users-run-a-cron-job-every-time-a-system-reboots/</link>
		<comments>http://insanelabs.com/linux/linux-crontab-notes-for-different-users-run-a-cron-job-every-time-a-system-reboots/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 06:47:59 +0000</pubDate>
		<dc:creator>Ali</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[cron]]></category>

		<guid isPermaLink="false">http://insanelabs.com/?p=202</guid>
		<description><![CDATA[Each user has its own crontab in Linux. Root crontab is only available to root and cannot be modified by other users. To edit your non-root crontab: crontab -e To list available crontab: crontab -l To delete: crontab -r Privileged users can access others crontab: crontab -u Run cron jobs as a different user: su [...]
Related posts:<ol>
<li><a href="http://insanelabs.com/linux/linux-share-a-directory-between-local-users/" rel='bookmark' title='Linux: Share a directory between local users' class="liinternal">Linux: Share a directory between local users</a></li>
<li><a href="http://insanelabs.com/debian/debian-sync-time-and-date-with-external-servers/" rel='bookmark' title='Debian: Sync time and date with external servers' class="liinternal">Debian: Sync time and date with external servers</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Each user has its own crontab in Linux. Root crontab is only available to root and cannot be modified by other users. To edit your non-root crontab:<br />
<span style="color: #ff6600;">crontab -e</span><code><br />
</code></p>
<p>To list available crontab:<br />
<span style="color: #ff6600;">crontab -l</span></p>
<p>To delete:<br />
<span style="color: #ff6600;">crontab -r</span></p>
<p>Privileged users can access others crontab:<br />
<span style="color: #ff6600;">crontab -u</span></p>
<p>Run cron jobs as a different user:</p>
<pre>su - &lt;user&gt; -c &lt;command or script&gt;</pre>
<p>Depending on your default editor crontab will either open in vi or nano. Crontab line format should look like:</p>
<pre># m h dom mon dow user command</pre>
<p>Under which you will have to specify when your cron job should run:</p>
<pre>m: minute of the day, from 0 to 59
h: hour of the day, from 0 to 23
dom: day of month, from 1 to 31
dow: day of week, from 1 to 7
user: user your cron job should run as
command: command or script that should run</pre>
<p>Root has access to two crontabs. One is accessible through crontab  and the other can be opened in your editor: <span style="color: #ff6600;">vi /etc/crontab</span> or <span style="color: #ff6600;">nano /etc/crontab</span>. Systemwide cron jobs should be added to /etc/crontab which take precedence over your regular cron.</p>
<p>A sample cron job should look like the following line. Here is a line I have in my crontab to sync time with external time servers:</p>
<pre># m h dom mon dow user command
01 0 * * * root ntpdate us.pool.ntp.org</pre>
<p>This cron job will sync time at 12:01 AM every night with pool.ntp.org</p>
<p>Tip: to create a cron job to run every time your system reboots (game servers, etc.) start your line with @reboot:</p>
<pre>@reboot /home/user/script</pre>
<p>Notice that you don&#8217;t need to specify anything but @reboot and path to executable. Regular and privileged users can both use this command.</p>
<p>Other commands:</p>
<pre>@reboot = run at boot and reboot only
@yearly = run at midnight Jan 1 (0 0 1 1 *)
@annually = run at midnight Jan 1(0 0 1 1 *)
@monthly = run at midnight on the first day of every month (0 0 1 * *)
@weekly = run at midnight every Sunday (0 0 * * 0)
@daily = run at midnight every day (0 0 * * *)
@midnight = run at midnight (0 0 * * *)
@hourly = run on the first second of every hour (0 * * * *)</pre>
<p>Related posts:<ol>
<li><a href="http://insanelabs.com/linux/linux-share-a-directory-between-local-users/" rel='bookmark' title='Linux: Share a directory between local users' class="liinternal">Linux: Share a directory between local users</a></li>
<li><a href="http://insanelabs.com/debian/debian-sync-time-and-date-with-external-servers/" rel='bookmark' title='Debian: Sync time and date with external servers' class="liinternal">Debian: Sync time and date with external servers</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://insanelabs.com/linux/linux-crontab-notes-for-different-users-run-a-cron-job-every-time-a-system-reboots/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

