summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--certbot.html8
-rw-r--r--cron.html174
-rw-r--r--index.html5
-rw-r--r--maintenance.html2
-rw-r--r--nginx.html7
-rw-r--r--pix/tor.pngbin0 -> 28118 bytes
-rw-r--r--tor.html78
7 files changed, 266 insertions, 8 deletions
diff --git a/certbot.html b/certbot.html
index dded807..cabf6cd 100644
--- a/certbot.html
+++ b/certbot.html
@@ -97,7 +97,7 @@ ufw allow 443</code></pre>
<p>
Of course, you don't want to have to remember to log in to renew them every three months, so it's easy to tell the server to automatically run this command.
- We will use a cronjob for this. Run the following command:
+ We will use a <a href="cron.html">cronjob</a> for this. Run the following command:
</p>
<pre><code>crontab -e</code></pre>
@@ -110,7 +110,7 @@ ufw allow 443</code></pre>
</aside>
<p>
- This <code>crontab</code> command will open up a file for editting.
+ This <code>crontab</code> command will open up a file for editing.
A crontab is a list of commands that your operating system will run automatically at certain times.
We are going to tell it to automatically try to renew our certificates every month so we never have to.
</p>
@@ -125,6 +125,10 @@ ufw allow 443</code></pre>
Save the file and exit to activate this cronjob.
</p>
+ <p>
+ For more on cron and crontabs please <a href="cron.html">click here!</a>
+ </p>
+
<span class=next><a href="html.html">Next: Use HTML to Make Simple Webpages</a></span>
</main>
<footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><li><a href="index.html"><img src="pix/chad.gif" alt="chad"></a></li><li><a href="rss.xml"><img src="pix/rss.svg" alt="RSS"></a></li><li><a href="pix/btc.png"><img src="pix/btc.svg" alt="BTC"></a></li><li><a href="pix/xmr.png"><img src="pix/xmr.svg" alt="XMR"></a></li><li><a href="https://github.com/lukesmithxyz/landchad"><img src="pix/git.svg" alt="Github"></a></footer>
diff --git a/cron.html b/cron.html
new file mode 100644
index 0000000..6b12269
--- /dev/null
+++ b/cron.html
@@ -0,0 +1,174 @@
+<!DOCTYPE html>
+<html lang=en>
+ <head>
+ <title>Cronjobs &ndash; LandChad.net</title>
+ <meta charset="utf-8"/>
+ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+ <link rel='stylesheet' type='text/css' href='style.css'>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'>
+ </head>
+<body>
+ <header><h1>Using Cronjobs to run scheduled tasks</h1></header>
+ <nav></nav>
+ <main>
+ <p>
+ Cron is a service that lets you run scheduled tasks. These tasks are called <strong> cronjobs. </strong> If you have already followed the initial course you will have already used cron when you set up certbot.
+ </p>
+ <h2> What tasks would I want to schedule? </h2>
+ <p>
+ You can schedule anything! Some examples of what you might have done already include:
+ <ul>
+ <li> <code> updatedb </code> to update your <code> locate </code> database </li>
+ <li> <code> certbot </code> to update renewing of your https certs </li>
+ </ul>
+ Some tasks that you might <em>want</em> to schedule may include:
+ <ul>
+ <li> Package updates - if you really just want to leave your server alone you can automated updating packages on your server </li>
+ <li> Backups - you may want to backup certain files every day and some every week, this is possible with cron </li>
+ </ul>
+ <p>
+ And many more, anything you can do can be turned into a cronjob.
+ </p>
+
+ <h2>Basic Cronjobs</h2>
+
+ <p>
+ This the preferred method for personal tasks and scripts, it's also the easiest to get started with. Run the command <code> crontab -e </code> to access your users crontab
+ </p>
+
+ <p>
+ Once you have figured out the command you want to run you need to figure out how often you want to run it and when. I am going to schedule my system updates once a week on at 3:30 AM on a Monday.
+ </p>
+ <p>
+ We now have to convert this time (Every Monday at 3:30 AM) into a cron time. Cron uses a simple but effective way of scheduling when to run things.
+ </p>
+ <p>
+ Crontab expressions look like this <code> * * * * * command-to-run </code>
+ The five elements before the command tell when the command is supposed to be run automatically.
+ <p>
+ So for our Monday at 3:30AM job we would do the following:
+ <p>
+ <pre><code> .---------------- minute (0 - 59)
+ | .------------- hour (0 - 23)
+ | | .---------- day of month (1 - 31)
+ | | | .------- month (1 - 12
+ | | | | .---- day of week (0 - 6)
+ | | | | |
+ * * * * *
+30 3 * * 1 apt -y update && apt -y dist-upgrade</code></pre>
+
+ <h3>Some notes</h3>
+ <ul>
+ <li>On the day of the week option, Sunday is 0 and counting up from there, Saturday will be 6.</li>
+ <li><code>*</code> designates "everything". Our command above has a <code>*</code> in the day of month and month columns. This means it will run regardless of the day of the month or month.</li>
+ <li>The hour option uses 24 hour time. 3 = 3AM, while use 15 for 3PM.</li>
+ </ul>
+
+ <h3>More examples</h3>
+ <p>
+ Let's add another job, our backup job (for the purposes of this our backup command is just called <code> backup</code>) We want to run <code> backup </code> Every evening at 11PM, once we work out the timings for this we can add the to the same file as the above by running <code> crontab -e </code> This would mean our full crontab would look like this:
+ <pre><code>0 23 * * * backup</code></pre>
+
+ <h3>Consecutive times</h3>
+
+ <p>
+ Suppose we want a command to run every weekday.
+ We know we can put <code>1</code> (Monday), but we can also use <code>1-5</code>
+ to signify from day 1 (Monday) to day 5 (Friday).
+ </p>
+
+ <pre><code>0 6 * * 1-5 echo "Wakey, wakey, wagie!" >> /home/wagie/alarm</code></pre>
+
+ <p>The above <code>echo</code> command runs every Monday through Friday at 6:00AM.</p>
+
+ <h3>Non-consecutive times</h3>
+
+ <p>
+ We can also randomly specify non-consecutive arguments with a comma.
+ Suppose you have a script you want to run at the midday of the 1st, 15th, and 20th day of every month.
+ You can specify that my putting <code>1,15,20</code> for the day of the month argument:
+ </p>
+
+ <pre><code>0 12 1,15,20 * * /usr/bin/pay_bills_script</code></pre>
+
+ <h3>"Every X minutes/days/months"</h3>
+
+ <p>We can also easily run a command very several minutes or months, without specifying the specific times:
+ </p>
+
+ <pre><code>*/15 * * * * updatedb</code></pre>
+
+ <p>
+ This cronjob will run the <code>updatedb</code> command every 15 minutes.
+ </p>
+
+ <h3>Beware of this Rookie Mistake Though...</h3>
+
+ <p>
+ Suppose you want to run a script once every other month.
+ You might be <em>tempted</em> write this:
+ </p>
+
+ <pre><code>* * * */2 *</code></pre>
+
+ <p>
+ That might <em>feel right</em>, but this script <em>will be running once every minute during that every other month</em>.
+ You should specify the first two arguments, because with <code>*</code> it will be running every minute and hour!
+ </p>
+
+ <pre><code>0 0 1 */2 *</code></pre>
+
+ <p>This makes the command run <em>only</em> at 0:00 (12:00AM) on the first day of every two months, which is what we really want.</p>
+
+ <p>
+ Consult the website <a href="https://crontab.guru">crontab.guru</a> for an intuitive and interactive tester of cronjobs.
+ </p>
+
+ <h2>User vs. Root Cronjobs</h2>
+
+ <p>
+ It is important to note that user accounts all have different cronjobs.
+ If you have a user account <code>chad</code> and edit his crontab with <code>crontab -e</code>,
+ the commands you add will be run as the <code>chad</code> user, not <code>root</code> or anyone else.
+ </p>
+
+ <p>
+ Bear in mind that if you need root access to run a particular command,
+ you will usually want to add it as root.
+ </p>
+
+ <h2>System-wide cron directories</h2>
+
+ <p>
+ <code>crontab -e</code> is the typical interface for adding cronjobs, but it's important to at least know that system-wide jobs are often stored in the file directory.
+ Some programs which need cronjobs will automatically install them in the following way.
+ </p>
+
+ <p>
+ Run the command <code> ls /etc/cron* </code> you should see a list of directories and there contents. The directories should be something like the below
+ <ul>
+ <li> /etc/cron.d <em> This is a crontab like the ones that you create with </em> <code> crontab -e </code> </li>
+ <li> /etc/cron.hourly </li>
+ <li> /etc/cron.daily </li>
+ <li> /etc/cron.weekly </li>
+ <li> /etc/cron.monthly </li>
+ </ul>
+
+ <p>
+ The directories cron.{hourly,daily,weekly,monthly} are where you can put <strong> scripts </strong> to run at those times. You don't put normal cron entries here. I prefer to use these directories for system wide jobs that don't relate to an individual user.
+ </p>
+
+ <h2>Contribution</h2>
+
+ <ul>
+ <li>Mark McNally -- <a href="https://mark.mcnally.je">website</a>, <a href="https://www.youtube.com/channel/UCMiInY8BhSUtCarO6uu6i_g">Youtube</a></li>
+ <li>Edits and examples by Luke</li>
+ </ul>
+
+
+
+ </main>
+ <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><li><a href="index.html"><img src="pix/chad.gif" alt="chad"></a></li><li><a href="rss.xml"><img src="pix/rss.svg" alt="RSS"></a></li><li><a href="pix/btc.png"><img src="pix/btc.svg" alt="BTC"></a></li><li><a href="pix/xmr.png"><img src="pix/xmr.svg" alt="XMR"></a></li><li><a href="https://github.com/lukesmithxyz/landchad"><img src="pix/git.svg" alt="Github"></a></footer>
+</body>
+</html>
diff --git a/index.html b/index.html
index be571ce..d42989c 100644
--- a/index.html
+++ b/index.html
@@ -54,11 +54,13 @@
<li><a href="bat.html"><img src="pix/bat.svg">Basic Attention Token (BAT)</a></li>
</ul>
- <h3 ol=other>Excellent Extras</h3>
+ <h3 id=other>Excellent Extras</h3>
<ul class=ll>
<li><a href="maintenance.html">How to maintain a server.</a></li>
<li><a href="sshkeys.html">Use your SSH keys to prevent hacking.</a></li>
<li><a href="nextcloud.html">Setting up a <img src="pix/nextcloud-logo.png" alt="nextcloud logo">Nextcloud Instance (file hosting and more)</a></li>
+ <li><a href="cron.html">Schedule tasks with Crontabs/Cronjobs.</a></li>
+ <li><a href="tor.html">Mirror your site on Tor.</a></li>
</ul>
<h2>In the Works...</h2>
@@ -92,7 +94,6 @@
</p>
<ul>
- <li>Cronjobs</li>
<li>IRC servers</li>
<li>Email webclients</li>
<li>Simple static site generators</li>
diff --git a/maintenance.html b/maintenance.html
index 5cdbb1a..264fe68 100644
--- a/maintenance.html
+++ b/maintenance.html
@@ -113,7 +113,7 @@ nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx /usr/share/man
/usr/share/nginx/modules-available/mod-stream.conf</code></pre>
<p>
- <code>updatedb</code> is an ideal candidate for a cronjob so you don't have to worry about running each time.
+ <code>updatedb</code> is an ideal candidate for a <a href="cron.html">cronjob</a> so you don't have to worry about running each time.
For example, adding the following to your crontab will run <code>updatedb</code> every 30 minutes:
</p>
<pre><code>*/30 * * * * /usr/bin/updatedb</code></pre>
diff --git a/nginx.html b/nginx.html
index 6023b4c..1b269db 100644
--- a/nginx.html
+++ b/nginx.html
@@ -172,7 +172,7 @@ This will appear on your website.
&lt;p&gt;This is my website. Thanks for stopping by!&lt;/p&gt;
&lt;p&gt;Now my website is live!&lt;/p&gt;</code></pre>
-<h3>Enable the site</h3>
+<h3 id=enable>Enable the site</h3>
<p>
Once you save that file, we can enable it making a link to it in the <code>sites-enabled</code> directory:
@@ -209,10 +209,11 @@ systemctl disable ufw</code></pre>
This keeps the firewall otherwise active.
</p>
-<pre><code>ufw allow http,https</code></pre>
+<pre><code>ufw allow 80
+ufw allow 443</code></pre>
<p>
-This will open port 80 and port 443. Port 80 is the canonical webserver port, while 443 is the port used for encrypted connections.
+Port 80 is the canonical webserver port, while 443 is the port used for encrypted connections.
We will certainly need that for the next page.
</p>
diff --git a/pix/tor.png b/pix/tor.png
new file mode 100644
index 0000000..1bac8e2
--- /dev/null
+++ b/pix/tor.png
Binary files differ
diff --git a/tor.html b/tor.html
new file mode 100644
index 0000000..1da2656
--- /dev/null
+++ b/tor.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html lang=en>
+ <head>
+ <title>Mirror your site over tor</title>
+ <meta charset="utf-8"/>
+ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+ <link rel='stylesheet' type='text/css' href='style.css'>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'>
+ </head>
+<body>
+ <header><h1>Mirror Your Site Over Tor <img src="pix/tor.png" alt="onion"/></h1></header>
+ <nav></nav>
+ <main>
+ <p>
+ Now that you have a website, why not offer it on a private alternative such as the onion network?
+ </p>
+ <aside>
+ <a href="https://landchad.net" >LandChad.net</a> does not condone
+ any illegal activities or websites on the dark web nor the usage of
+ this tutorial to launch such sites.
+ </aside>
+
+ <h2>Setting up Tor</h2>
+
+ <p>First, install tor. On Debian it's as simple as:</p>
+
+ <pre><code> apt install tor</code></pre>
+
+ <p>Then edit the file <code>/etc/tor/torrc</code>, uncommenting the following lines:</p>
+ <pre><code> HiddenServiceDir /var/lib/tor/hidden_service/
+ HiddenServicePort 80 127.0.0.1:80</code></pre>
+ <aside>
+ <h4>Optional: Running multiple onion services</h4>
+ <p>If you want to forward multiple virtual ports for a single onion
+ service, just add more HiddenServicePort lines (replace the 80 with any unoccupied port).
+ </p>
+ <p>If you want to run multiple onion services from the same Tor client, just add another
+ HiddenServiceDir line.</p>
+ </aside>
+
+ <p>Now restart tor</p>
+ <pre><code> systemctl enable --now tor </code></pre>
+
+ <p>If the next command outputs <q>active</q> in green you're golden!</p>
+ <pre><code> systemctl status tor</code></pre>
+
+ <p>Now you're server is on the dark web. The following command will give you your onion address:</p>
+ <pre><code> cat /var/lib/tor/hidden_service/hostname</code></pre>
+
+ <h2>Adding the Nginx Config</h2>
+ <p>
+ From here, the steps are almost identical to setting up a normal website configuration file.
+ Follow the steps as if you were making a new website on the webserver
+ <a href="nginx.html">tutorial</a> up until the server block of code. Instead, paste this:
+ </p>
+
+ <pre><code> server {
+ listen 127.0.0.1:80 ;
+ root /var/www/<strong>landchad</strong> ;
+ index index.html ;
+ server_name <strong>your-onion-address</strong>.onion ;
+ }</code></pre>
+
+ <aside>
+ <h4>Clarification</h4>
+ <p>Nginx will listen on port 80 for your <em>server's</em> localhost.</p>
+ <p>The <code>root</code> line is the path to whichever website of yours you'd like to mirror.</p>
+ </aside>
+ <p>
+ From here we are almost done, all we have to do is enable the site and reload nginx which is also covered in <a href="nginx.html#enable">the webserver tutorial</a>.
+ </p>
+ <strong>Contributor</strong> - <a href="https://tomfasano.xyz" target="_blank">tomfasano.xyz</a>
+
+ </main>
+ <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><li><a href="index.html"><img src="pix/chad.gif" alt="chad"></a></li><li><a href="rss.xml"><img src="pix/rss.svg" alt="RSS"></a></li><li><a href="pix/btc.png"><img src="pix/btc.svg" alt="BTC"></a></li><li><a href="pix/xmr.png"><img src="pix/xmr.svg" alt="XMR"></a></li><li><a href="https://github.com/lukesmithxyz/landchad"><img src="pix/git.svg" alt="Github"></a></footer>
+</body>
+</html>