- MCP server with stdio transport for local use - Search episodes, transcripts, hosts, and series - 4,511 episodes with metadata and transcripts - Data loader with in-memory JSON storage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
124 lines
11 KiB
Plaintext
124 lines
11 KiB
Plaintext
Episode: 2003
|
|
Title: HPR2003: Using the Incron file watching daemon
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2003/hpr2003.mp3
|
|
Transcribed: 2025-10-18 13:10:29
|
|
|
|
---
|
|
|
|
This is HPR episode 2003 entitled, using the Incron file watching demon and in part of the series bash-crypting.
|
|
It is hosted by me using it and in about 12 minutes long.
|
|
The summary is, I briefly introduce the Incron file watching demon and give an example of how I use it.
|
|
This episode of HPR is brought to you by an honesthost.com.
|
|
Get 15% discount on all shared hosting with the offer code HPR15. That's HPR15.
|
|
Better web hosting that's honest and fair at an honesthost.com.
|
|
Hey HackerPupWook Radio, this is Be Easy once again signing in.
|
|
Coming in with another episode, this time I'm going to be talking about the file watching demon called Incron.
|
|
Now I said I would do something with this one before and now I'm going to do it because it's a pretty
|
|
cool utility and I don't use it all the time but when I do it's always very useful and I can see
|
|
how it has lots of applications, situations where the haven't thought of. So with no further ado,
|
|
here we go. So from the man page, Incron or more specifically Incron tab, which related to
|
|
Cron, Incron tab is a file that contains instructions to the Incron D Damon of the general form.
|
|
Run this command on these files, events. There are two categories of tables, system tables with
|
|
fruit privileges and user tables with user privileges. And so instead of reading the entire
|
|
rest of the man page, I'll just let you read it. But if you're installing it, it's usually just
|
|
called Incron and whatever repository you're looking at. As far as I know, it's only available for
|
|
Linux. I'm not exactly sure about BSD. I could probably look that up. But it is a very useful tool.
|
|
So one thing they can do with it and something I use it for is to automatically have tasks happen
|
|
when a file is either created, modified, deleted, moved, changed status. And they're the format
|
|
goes the path, the mask and the command. Now the mask is usually what you want to do.
|
|
And it's usually the event symbols. And so the event symbols are in access, which means when
|
|
the file is accessed in a tribe, which is when metadata about it, the file change, like permissions
|
|
or D timestamps, and close right and no right and create and delete and delete shelf and modify
|
|
and move shelf and move from and move to and open. And then there's in all events and and don't
|
|
follow in one shot and in only there. And those are all separated. All those different words are
|
|
separated with underscores. But the one I'm going to talk about right now is Increate. And so
|
|
that means when a new file is in the directory, do something to it. And what I use it for
|
|
in this example is I have a Raspberry Pi 2 with PanDoc installed. And I've talked about PanDoc
|
|
before. It's a utility that is used to create multiple types of documents from other types
|
|
of documents. For instance, from markdown to HTML or to PDF or from from wiki.no, you know,
|
|
the wiki.no to PDF or HTML or even stuff like reveal.js slides or slidey.js slides.
|
|
I use it all the time. And I have lots of other computers that I don't necessarily want install
|
|
PanDoc on because PanDoc itself is not that big. But if it's depending on what distribution you
|
|
download, you download it with sometimes you have to install all of Haskell with it. And other times
|
|
you have to also install if you want to use PDFs, you always have to install text live. And the
|
|
minimum amount of text live is like a half a gig. So if you're hard up on hard drive space,
|
|
you might not want such a heavy program. Like I have two computers that I use all the time. Both
|
|
of them have 32 gig SSDs. I know I could put faster ones in bigger ones in there. I have no
|
|
reason to. But anyway, so after that, there is some wild cards that you can use to identify the
|
|
files and the directories that the wild cards are dollar sign at, which is the watch file system.
|
|
So if you're going to refer to the path of it in the command that you're writing, it is dollar sign
|
|
at symbol or on the American keyboard is the shift to. And then you also have the dollar sign
|
|
pound or dial sign, you know, the little tic-tac-toe looking thing, which is the shift three. And that is
|
|
the event related file name. So if you want to the full the full path of a file, it would be
|
|
dollar sign at slash dollar sign pound. And then there's also dollar sign percent and dollar sign
|
|
ampersand and those for or for event tags. And I haven't used event tags. I haven't had to use
|
|
for them yet. So I'm not going to talk about them because I'm not exactly sure how they work and
|
|
how best to use them. And the main page it has to be examples, but it's kind of a generic example.
|
|
I want to go over a specific example of how I use it. So in particular, I have a couple of folders
|
|
on my Raspberry Pi inside of a folder and on the inside of the user's home folder. There's a
|
|
directory called docs inside of docs. There's all these other folders. One for letters, one for
|
|
notes, one for things I will turn to PDFs, one for reveal.js slides, another one for standard
|
|
operating procedures, and another one for validation protocols, some of the things I do for work.
|
|
In any one of those, there might be a I will throw a markdown file because as I've said,
|
|
another episode, I write almost exclusively in markdown. And I have developed these really
|
|
specific templates that all the documents that I want to write go into. And they, if it's a note,
|
|
I always want to output it in a certain format. If it's a standard operating procedure, I always
|
|
want it in the same format. And it's annoying to have to reformat those. And I can use templates and
|
|
then copy and paste stuff in there. But it's anyone working with where processes knows that,
|
|
copying paste and then updating the styles is not very fast. If you want to do it really quickly,
|
|
and you want to do it consistently the same way every time. So instead, I also have one for
|
|
letters. If I want to write a letter that needs to be mailed and that's a professional format
|
|
at one, I have one for that too, which uses, which is a PDF, which inserts a signature and a whole
|
|
bunch of other stuff. So it's pretty cool. But what I do is I write the pen doc command in
|
|
a.sh file. So in the shell command, and all I have to do inside of my cron tab. So to use,
|
|
to make a new cron tab job, you have to get to the cron table in cron table, which is just like
|
|
cron. So if I keep on mixing up, that's why it's very similar to cron. So if you ever have used
|
|
cron before, which is the kind of the scheduler. Instead of going cron tab dash A, you do
|
|
in cron tab dash A. And that will bring you to your your cron your in contact. So for instance,
|
|
on my first line of my in cron table, I have slash home slash user slash docs slash PDF. So in that
|
|
directory, the next command is in underscore create. And then I say slash home slash user mkpdf.sh
|
|
And then I have dollar sign at slash dollar sign pound, which if I read it all the way out, it's
|
|
in the director of slash home slash users slash docs slash PDF. When a file is created, run the
|
|
command mkpdf.sh on the file of the full path. And so what that file looks like is very simply,
|
|
it's a bash script that has file name and I get the base name of the file. So you know,
|
|
so my mkpdf takes one argument, which is the file name. So I get the base name of the file. I change
|
|
the I change to that md to dot PDF. I run a markdown command that tells about the geometry of the
|
|
page and the fonts and anything else and and the template that I use. And then I say dash O, put it
|
|
into the slash home slash pie slash docs slash done directory and then remove that original file.
|
|
I probably could move that original file to a completed folder so that if everyone's
|
|
to do it again, I could and maybe that's something I'll do in the future. But for now, I just remove it
|
|
so that when I go back and look at the directory, I can tell that it's done. Because if you don't,
|
|
you could look in the done folder to see if it's done. But it's for me, it's just easier to look
|
|
in the pending folder to see how many have already completed and how many still need to be completed.
|
|
And so, you know, it's a pretty simple thing. So after I throw a file in there, the job starts to
|
|
run and if you do a tail F on the slash bar slash syslog, you can see that there's an event
|
|
in the syslog that says in crowns running and it says the command name and the file name. And then
|
|
so you know that it's working. Or if you open up top or each top, you'll see that the command starts
|
|
in and then it'll start running. And so what I usually do is I have the root directory, so the
|
|
home directory of that user on the Raspberry Pi mounted to my different workstations.
|
|
And when I have a document that I want to throw into one of those folders, I just open it up,
|
|
drag it from where I'm working on and drag it in there, or you know, control C and then control V
|
|
in the other directory. Depending on what I'm doing and how complicated it is, not big the file is,
|
|
come back a couple seconds or a couple minutes later. Usually no longer than 60 seconds.
|
|
And then pick up the file in the drop off spot in the dead folder and email it, continue to work
|
|
on if there's post processing that I want to do on it or anything else that my job might acquire.
|
|
It's really convenient. It allows it's doing, it's kind of the Unix philosophy of have, you know,
|
|
do one job really well. So that Raspberry Pi is pretty much only doing a couple of little
|
|
medial tasks like running Pandak, running a couple of little things on in-crond and crond.
|
|
That's all days in-crond and crond jobs. And you know, it's very useful. There's, if you think
|
|
about the nature of this command, it's very powerful. And if you've ever used Windows Systems,
|
|
and you've ever tried to use a Demon or Watcher on Windows Systems, it's not a straightforward
|
|
and to get something that is this straightforward and the simple, you should cost a pretty good amount
|
|
of money. So I really appreciate having a command like this in my, just a simple install command
|
|
the way from any Linux distribution I have. And I appreciate your time once again on Hacker Public
|
|
Radio. This is easy signing off.
|
|
You've been listening to Hacker Public Radio at Hacker Public Radio dot org.
|
|
We are a community podcast network that releases shows every weekday, Monday through Friday.
|
|
Today's show, like all our shows, was contributed by an HBR listener like yourself.
|
|
If you ever thought of recording a podcast, then click on our contribute link to find out
|
|
how easy it really is. Hacker Public Radio was founded by the digital dog pound and the
|
|
infonomicum computer club and is part of the binary revolution at binrev.com. If you have
|
|
comments on today's show, please email the host directly, leave a comment on the website
|
|
or record a follow-up episode yourself. Unless otherwise stated, today's show is released on
|
|
creative comments, attribution, share a light, 3.0 license.
|