mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-30 22:57:59 +00:00
Update notebook as of 2021-08-07
With the few updates on more learning, writing, and some forward calls for archiving which I'll be jotting down for some ideas soon.
This commit is contained in:
parent
7dff55219a
commit
f868f3b3da
@ -3,7 +3,7 @@
|
||||
:END:
|
||||
#+title: Maintain your own digital library
|
||||
#+date: "2020-04-14 18:28:55 +08:00"
|
||||
#+date_modified: "2021-05-20 15:04:55 +08:00"
|
||||
#+date_modified: "2021-08-07 11:20:29 +08:00"
|
||||
#+language: en
|
||||
#+tags: personal-info-management
|
||||
|
||||
@ -27,24 +27,12 @@ On the other hand, personal digital libraries are basically personal information
|
||||
I have been thinking of creating a digital library for myself.
|
||||
These are the tools I've been using for my experiment:
|
||||
|
||||
- Zotero as my reference management library.
|
||||
- Exiftool for annotating my files with metadata.
|
||||
- Recoll as the search interface.
|
||||
- Org-Mode with org-roam as my personal wiki/knowledge base.
|
||||
- roam:Zotero as my reference management library.
|
||||
- Exiftool for annotating my files with [[id:ccb3bc14-a801-4ed0-b066-50b1bcd853aa][File metadata]].
|
||||
- [[id:253c59a3-f5ba-4d77-b535-7447a512945d][Recoll]] as the search interface.
|
||||
- [[id:c422175a-5b65-4311-8cc6-11efd55364e8][Org mode]] with org-roam as my personal wiki/knowledge base as my [[id:0d2264a6-e487-4761-818a-d17d2833120f][Note-taking]] system.
|
||||
|
||||
There are a couple of minor things such as Buku as my bookmarks manager, lf as a file explorer, mpv for multimedia, and Firefox as my web browser.
|
||||
|
||||
The digital library does not have to be integrated as the established libraries, you just have to loosely connect a system with each of the components of your library.
|
||||
My digital library are fragmented with each component located in its own directory (e.g., Zotero data directory is in ~$HOME/Documents/references~, books and documents are at ~$HOME/Documents/books~, wiki at ~$HOME/writings/wiki~) but it is a non-problem for me and it is easy to solve if it's a problem.
|
||||
|
||||
|
||||
|
||||
|
||||
* Related resources
|
||||
|
||||
- https://github.com/DSpace/DSpace
|
||||
- https://ieeexplore.ieee.org/Xplore/home.jsp
|
||||
- https://unpaywall.org/
|
||||
- https://www.loc.gov/catworkshop/courses/metadatastandards/pdf/MSTraineeManual.pdf
|
||||
|
||||
For more digital library examples, see https://en.wikipedia.org/wiki/List_of_digital_library_projects.
|
||||
|
@ -3,7 +3,7 @@
|
||||
:END:
|
||||
#+title: Create an inbox to store your thoughts
|
||||
#+date: "2020-06-25 12:37:23 +08:00"
|
||||
#+date_modified: "2021-07-19 18:54:39 +08:00"
|
||||
#+date_modified: "2021-08-07 11:06:17 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ The following list shows a few examples what you can store into dedicated inboxe
|
||||
- Tasks can then be tracked, reminding what and/or when to be done.
|
||||
- You can create an inbox for various links, [[id:db298171-834d-4348-92a8-68e3f830d5d0][Collecting information to learn new skills]].
|
||||
- [[id:92a10fe2-f4d1-4e5e-b5f4-3779db13a2e5][Create roadmaps to stay on track]] as a way to learn new skills.
|
||||
- [[id:03289346-3154-4fa1-9bfe-70158012fb5a][Store a sketchbook for your narratives]] allowing you to build your initial imagining of creating a world especially for fantasy settings.
|
||||
|
||||
Like our emails, our writing inbox should be cleaned up each time we visit our inbox.
|
||||
Not all of them are going to be important so feel free to remove entries that are not in need.
|
||||
|
@ -3,7 +3,7 @@
|
||||
:END:
|
||||
#+title: Fleeting notes
|
||||
#+date: "2020-06-25 13:12:09 +08:00"
|
||||
#+date_modified: "2021-07-05 13:13:49 +08:00"
|
||||
#+date_modified: "2021-08-07 11:13:34 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
@ -17,3 +17,6 @@ Here's how I make things happen with them.
|
||||
- With messy thoughts and inputs, you should [[id:810dc8b6-db64-4c80-a0aa-f9e6d5fa4acf][Create an inbox to store your thoughts]] all in one place including failures as [[id:c886bc6d-e9dc-4f62-8841-59123236eda0][Failed ideas can be repurposed]].
|
||||
- You could [[id:799c5a72-2e8f-48a3-a22d-6657b9d1c05d][Apply search tools and techniques for your digital library]] to make things easier.
|
||||
- Then, select certain fleeting notes and improve upon them eventually creating evergreen notes — [[id:05a39f96-fb1c-4d71-9be1-fc4c2e251e8f][Start small and improve later]].
|
||||
|
||||
That said, [[id:e42758b5-e355-4a01-8d03-5bba518fd201][Fleeting notes makes up most of our thoughts]].
|
||||
After all, it is where most of our transient knowledge are being recorded.
|
||||
|
@ -3,14 +3,14 @@
|
||||
:END:
|
||||
#+title: Prefer referencing over remembering
|
||||
#+date: "2021-04-06 22:25:17 +08:00"
|
||||
#+date_modified: "2021-07-28 13:07:51 +08:00"
|
||||
#+date_modified: "2021-08-07 11:01:01 +08:00"
|
||||
#+language: en
|
||||
#+tags: personal-info-management
|
||||
|
||||
|
||||
It makes for less cognitive overhead.
|
||||
This is especially true in the age of internet where information is widely distributed.
|
||||
Even without the internet, however, it is still useful to find ways to refer to things or store them locally whether by archiving or creating related notes.
|
||||
Even without the internet, however, it is still useful to find ways to refer to things or store them locally whether by roam:Archiving or [[id:0d2264a6-e487-4761-818a-d17d2833120f][Note-taking]].
|
||||
|
||||
This doesn't mean that you should avert remembering, that would be silly as [[id:c0e4fb0e-68f2-4db4-8c3e-f5a7845738c3][Understanding comes first from memory]].
|
||||
You're still trying to understand a concept, after all.
|
||||
|
@ -3,18 +3,18 @@
|
||||
:END:
|
||||
#+title: Unnecessary optimizations cripple progress
|
||||
#+date: "2021-07-05 12:36:41 +08:00"
|
||||
#+date_modified: "2021-07-19 16:05:54 +08:00"
|
||||
#+date_modified: "2021-08-07 10:58:04 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
- while [[id:0e2c9eaf-f12a-47b2-9c9c-d1a590db131b][Involuntary attention switch is good for preventing tunnel vision]] — e.g., trying out new things, window shopping for better tools — it can go into a case of optimizing every choice
|
||||
- this is a form of analyzing too much except we're acting upon our choices;
|
||||
remember: [[id:03cd9fad-e187-4939-9347-1a034c6efbe2][Overanalyzing slow you down]]
|
||||
- this is a form of [[id:03cd9fad-e187-4939-9347-1a034c6efbe2][Overanalyzing slow you down]]
|
||||
- additionally, you could think of this addiction from taking too much advantages as you can;
|
||||
it always create the impression that there is an absolute way to do it and you just haven't figured it out yet;
|
||||
recall that [[id:9a9163d7-502b-4540-b723-e15afba1e917][Tradeoffs lock yourself in a position]]
|
||||
- unnecessary optimizations are unnecessary wasting of time that could've been used for something else more worthy;
|
||||
the problem, however, is it can be addicting
|
||||
in a way, you are [[id:9138397a-a965-45e9-97ea-71849e8d4f94][Overlearning]];
|
||||
the problem, however, is it can be addicting as you dig deeper into the rabbithole
|
||||
- this is affecting people of all walks of life that it has various names: productivity porn, yak shaving, and pre-optimizing software;
|
||||
in other words, the perfectionist stereotype
|
||||
- a lot of the improvements we do often comes from new ideas;
|
||||
|
@ -3,12 +3,13 @@
|
||||
:END:
|
||||
#+title: Skill-building
|
||||
#+date: "2021-07-09 19:20:50 +08:00"
|
||||
#+date_modified: "2021-07-28 11:27:10 +08:00"
|
||||
#+date_modified: "2021-08-07 11:11:05 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
- [[id:92a10fe2-f4d1-4e5e-b5f4-3779db13a2e5][Create roadmaps to stay on track]] as a way to plan ahead
|
||||
- [[id:1a6187c9-6c79-4378-bf8d-935c8a3d9167][Learning a new skill often starts from specific places]].
|
||||
- [[id:f2012707-1220-4bf4-8e42-f558f19ca178][Learn with the materials intended for kids]] as a starting place.
|
||||
- [[id:0dbfee88-cdce-48d1-9a10-23fc12d9bcd5][Refer to advanced resources when skill-building for a solid short-term goal]].
|
||||
- Get into [[id:db298171-834d-4348-92a8-68e3f830d5d0][Collecting information to learn new skills]].
|
||||
- Learn a thing or two about the [[id:06df5d69-12ac-4e98-8013-ac54d29aa80c][Learning process]] and [[id:125ca096-9769-465f-b923-ed1fd7956ae0][Learning techniques]].
|
||||
|
@ -3,7 +3,7 @@
|
||||
:END:
|
||||
#+title: Note-taking should make better thinking
|
||||
#+date: "2021-07-11 20:33:13 +08:00"
|
||||
#+date_modified: "2021-07-19 14:39:15 +08:00"
|
||||
#+date_modified: "2021-08-07 11:19:15 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
some people like to take note for the sake of taking note;
|
||||
some may even get into addiction to optimization as [[id:b62c61f1-ee12-4bd9-b59a-ec6eafe29f38][Unnecessary optimizations cripple progress]]
|
||||
- however, this is not an [[id:1bdbdcfa-98f9-4d08-a0dc-ad2f1b9b9ec9][Advice shouldn't be taken literally]];
|
||||
not all note-taking sessions should be striving towards better thinking
|
||||
not all note-taking sessions should be striving towards better thinking as it can be used for recreational purposes
|
||||
- we can do [[id:2667d942-48b6-4d1e-b92b-15c2dab645ed][Switching between different topics makes new perspective]] by doing some writing from our stream of thoughts instead of actively restructuring how do we present the topic in some way
|
||||
- people often write down fleeting knowledge;
|
||||
it isn't a bad practice as [[id:c0e4fb0e-68f2-4db4-8c3e-f5a7845738c3][Understanding comes first from memory]];
|
||||
it all comes down to how they manage them (see [[id:66337935-420c-40e6-81a6-f74ab0965ed5][Maintain your own digital library]])
|
||||
|
7
notebook/2021-07-22-14-09-26.org
Normal file
7
notebook/2021-07-22-14-09-26.org
Normal file
@ -0,0 +1,7 @@
|
||||
:PROPERTIES:
|
||||
:ID: 4b33103b-7f64-4b51-8f03-cac06d4001bb
|
||||
:END:
|
||||
#+title: Programming
|
||||
#+date: 2021-07-22 14:09:26 +08:00
|
||||
#+date_modified: 2021-07-22 14:09:29 +08:00
|
||||
#+language: en
|
7
notebook/2021-07-22-14-09-32.org
Normal file
7
notebook/2021-07-22-14-09-32.org
Normal file
@ -0,0 +1,7 @@
|
||||
:PROPERTIES:
|
||||
:ID: 022bc306-973d-4efe-ae76-d194a0ce1fca
|
||||
:END:
|
||||
#+title: 3D modelling
|
||||
#+date: 2021-07-22 14:09:32 +08:00
|
||||
#+date_modified: 2021-07-22 14:09:35 +08:00
|
||||
#+language: en
|
7
notebook/2021-07-22-14-25-13.org
Normal file
7
notebook/2021-07-22-14-25-13.org
Normal file
@ -0,0 +1,7 @@
|
||||
:PROPERTIES:
|
||||
:ID: e8c1218f-35a4-4dd3-a174-5d8f848b74b2
|
||||
:END:
|
||||
#+title: Free software
|
||||
#+date: 2021-07-22 14:25:13 +08:00
|
||||
#+date_modified: 2021-07-22 14:25:17 +08:00
|
||||
#+language: en
|
@ -3,17 +3,19 @@
|
||||
:END:
|
||||
#+title: Specific use cases are better than step-by-step tutorials
|
||||
#+date: 2021-08-01 07:50:47 +08:00
|
||||
#+date_modified: 2021-08-01 07:50:55 +08:00
|
||||
#+date_modified: 2021-08-07 11:37:19 +08:00
|
||||
#+language: en
|
||||
|
||||
|
||||
- a written specific use case showcases multiple things;
|
||||
a step-by-step tutorial mostly follow one with a fixed path
|
||||
a step-by-step tutorial mostly follow one with a fixed path;
|
||||
this enables the audience to do some interleaving as [[id:2667d942-48b6-4d1e-b92b-15c2dab645ed][Switching between different topics makes new perspective]]
|
||||
- usually because it [[id:3a605fb2-b867-41c2-bcf9-00ef772808e5][Show the result at the front]];
|
||||
similar reasons as to why [[id:e158b742-53c7-4442-9af3-489ea8240af9][Examples and stories are more memorable than explanations]]
|
||||
- examples:
|
||||
+ devlogs which a lot of the [[roam:Game development]] creates
|
||||
+ a lot of blog posts that tackles only one specific thing by its author usually to make them remember that thing
|
||||
+ showcases
|
||||
- from a content creator perspective, it creates more interesting options (e.g., skits, persona) that are usually unneeded in a tutorial;
|
||||
it can take advantage of our tendency to [[id:9a11ef31-b2a7-43a9-a7a9-48f191838c6e][Prefer referencing over remembering]] by being more memorable
|
||||
- with it, we can [[id:0dbfee88-cdce-48d1-9a10-23fc12d9bcd5][Refer to advanced resources when skill-building for a solid short-term goal]]
|
||||
|
13
notebook/2021-08-07-10-53-10.org
Normal file
13
notebook/2021-08-07-10-53-10.org
Normal file
@ -0,0 +1,13 @@
|
||||
:PROPERTIES:
|
||||
:ID: 03289346-3154-4fa1-9bfe-70158012fb5a
|
||||
:END:
|
||||
#+title: Store a sketchbook for your narratives
|
||||
#+date: 2021-08-07 10:53:10 +08:00
|
||||
#+date_modified: 2021-08-07 11:07:31 +08:00
|
||||
#+language: en
|
||||
|
||||
|
||||
- [[id:810dc8b6-db64-4c80-a0aa-f9e6d5fa4acf][Create an inbox to store your thoughts]] that is dedicated for a fictional world
|
||||
- very useful for [[id:815b2beb-40a0-4e79-9097-5b688189ad5b][Writing]] narratives to create a good consistent world especially for fantasy settings
|
||||
- one of the good use cases for [[id:583852e4-e56f-469b-89bc-9e5a832c9f04][Backlinks]], creating a quick interface for linked objects
|
||||
- interestingly, note-taking systems that emphasizes linking such as [[id:4259636e-e0e8-49e4-8210-758ec59728a3][Zettelkasten]] makes this a good tool for this
|
14
notebook/2021-08-07-11-10-27.org
Normal file
14
notebook/2021-08-07-11-10-27.org
Normal file
@ -0,0 +1,14 @@
|
||||
:PROPERTIES:
|
||||
:ID: f2012707-1220-4bf4-8e42-f558f19ca178
|
||||
:END:
|
||||
#+title: Learn with the materials intended for kids
|
||||
#+date: 2021-08-07 11:10:27 +08:00
|
||||
#+date_modified: 2021-08-07 11:10:36 +08:00
|
||||
#+language: en
|
||||
|
||||
|
||||
- a lot of the things have been simplified, making it easier to follow
|
||||
- however, you could present into problems where it can be too simple
|
||||
- most people tends to underestimate these types of educational materials, most likely due to the [[id:9986bd9e-763e-497e-a35d-ecd0aa93f408][Presence of the material fools students into learning]]
|
||||
- at the same time, you could do [[id:2667d942-48b6-4d1e-b92b-15c2dab645ed][Switching between different topics makes new perspective]];
|
||||
[[id:0dbfee88-cdce-48d1-9a10-23fc12d9bcd5][Refer to advanced resources when skill-building for a solid short-term goal]]
|
13
notebook/2021-08-07-11-11-35.org
Normal file
13
notebook/2021-08-07-11-11-35.org
Normal file
@ -0,0 +1,13 @@
|
||||
:PROPERTIES:
|
||||
:ID: e42758b5-e355-4a01-8d03-5bba518fd201
|
||||
:END:
|
||||
#+title: Fleeting notes makes up most of our thoughts
|
||||
#+date: 2021-08-07 11:11:35 +08:00
|
||||
#+date_modified: 2021-08-07 11:15:10 +08:00
|
||||
#+language: en
|
||||
|
||||
|
||||
- [[id:864a9242-eb10-44ad-81b7-c237276523e5][We know more compared to what we understood]];
|
||||
we have filtered most of it into something either for the immediate task or for the future ventures
|
||||
- [[id:3d1c0313-fa3d-4b18-b435-51d3837e3e2c][Fleeting notes]] is a mental scratchpad;
|
||||
with a messy notebook, it can be made to generate ideas as if to [[id:fa53b258-a6c0-4817-9b8c-ead294e6772a][Store a dedicated inbox for randomly generated ideas]]
|
@ -3,7 +3,7 @@
|
||||
:END:
|
||||
#+title: Tunnel vision
|
||||
#+date: "2021-07-15 22:21:04 +08:00"
|
||||
#+date_modified: "2021-07-19 17:50:51 +08:00"
|
||||
#+date_modified: "2021-08-07 11:35:53 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
@ -15,9 +15,11 @@
|
||||
- we may also have to [[roam:Learn how to forget]];
|
||||
in a world of quick and constant changes, learning new rules and topics takes up mental resources;
|
||||
we have to assign some garbage day at some point;
|
||||
unfortunately, we cannot easily do that from our experience as creates dogmatic mindset, that is, to survive by sticking to what we know
|
||||
unfortunately, we cannot easily do that from our experience as we try to survive by sticking to what we know
|
||||
- it is present on most experts with their experience on the field;
|
||||
but this is also a potential problem for students in training where certain principles are taught then encountering a new idea overall
|
||||
- a lot of the teaching focuses on explaining things;
|
||||
one could try to use specific use cases as [[id:e5d4cb07-d0e6-4bda-b2fc-426240b04f78][Specific use cases are better than step-by-step tutorials]]
|
||||
- This is the reason why most of the discoveries are made either by young people or those who haven't formally trained for the original field.
|
||||
- to combat against this, we do [[id:2667d942-48b6-4d1e-b92b-15c2dab645ed][Switching between different topics makes new perspective]]
|
||||
- by the same principle, we could also let our attention switch at times;
|
||||
|
@ -3,7 +3,7 @@
|
||||
:END:
|
||||
#+title: Exploring systemd features
|
||||
#+date: "2021-05-20 22:37:22 +08:00"
|
||||
#+date_modified: "2021-07-28 12:50:06 +08:00"
|
||||
#+date_modified: "2021-08-02 12:02:46 +08:00"
|
||||
#+language: en
|
||||
#+property: header-args :eval no
|
||||
|
||||
@ -11,6 +11,12 @@
|
||||
systemd is a big tool for a big system.
|
||||
Let's explore some of them from a perspective of a wannabe power user.
|
||||
|
||||
Among other things, it has the following list of features.
|
||||
|
||||
- [[id:f1b21fc8-86a5-47cd-b3d8-da6ac7a34427][systemd timers]] which can replace cron for task scheduling.
|
||||
- [[id:cd5f0d04-d9bb-44e8-a0f2-630ea58c1e94][systemd services]] along with the usual antics of a service manager such as managing dependencies and commands to run when killed.
|
||||
- [[id:a602f900-cdcf-4090-9278-d5926d80eedc][systemd transient units]] for quickly creating and scheduling one-off services.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -41,89 +47,6 @@ systemctl --user start $SERVICE
|
||||
|
||||
|
||||
|
||||
* systemd timers as cron replacement
|
||||
|
||||
You can schedule tasks with timers.
|
||||
If systemd is compiled with the feature, it makes cron unnecessary.
|
||||
|
||||
systemd has different ways to denote time.
|
||||
|
||||
- Timespans denote the duration — e.g., =100 seconds=, =5M 3w=.
|
||||
- Timestamps refer to a specific point in time — e.g., =2021-04-02=, =today=, =now=.
|
||||
- Calendar events can refer to more than one point of time — e.g., =*-*-4/2=, =Sun,Wed,Fri *-1/2-1/8=.
|
||||
|
||||
Here's an example of setting a timer for an example backup service.
|
||||
The following timer unit sets it to execute every day at 18:00.
|
||||
|
||||
#+begin_src ini
|
||||
[Unit]
|
||||
Description=A deduplicated backup from my computer
|
||||
Documentation=man:borg(1) https://borgbackup.readthedocs.io/
|
||||
|
||||
[Timer]
|
||||
Unit=borg-backup.service
|
||||
OnCalendar=*-*-* 18:00:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
#+end_src
|
||||
|
||||
This will trigger =borg-backup.service= from the load path.
|
||||
But you can omit it if you named the timer unit file similarly (e.g., =borg-backup.timer= with =borg-backup.service=).
|
||||
|
||||
You can find more information about it from the =systemd.time.5= manual page.
|
||||
Furthermore, systemd has a testing tool for time with ~systemd-analyze {timespan,timestamp,calendar}~.
|
||||
|
||||
#+begin_src shell :eval yes
|
||||
printf "Timespan example:\n"
|
||||
printf "..............\n"
|
||||
systemd-analyze timespan 4000min
|
||||
printf "..............\n\n"
|
||||
|
||||
printf "Timestamp example:\n"
|
||||
printf "..............\n"
|
||||
systemd-analyze timestamp 2021-07-01
|
||||
printf "..............\n\n"
|
||||
|
||||
printf "Calendar example:\n"
|
||||
printf "..............\n"
|
||||
systemd-analyze calendar "*-1/4-5 0/2:00:00"
|
||||
printf "..............\n\n"
|
||||
#+end_src
|
||||
|
||||
#+results:
|
||||
#+begin_example
|
||||
Timespan example:
|
||||
..............
|
||||
Original: 4000min
|
||||
μs: 240000000000
|
||||
Human: 2d 18h 40min
|
||||
..............
|
||||
|
||||
Timestamp example:
|
||||
..............
|
||||
Original form: 2021-07-01
|
||||
Normalized form: Thu 2021-07-01 00:00:00 PST
|
||||
(in UTC): Wed 2021-06-30 16:00:00 UTC
|
||||
UNIX seconds: @1625068800
|
||||
From now: 2 weeks 4 days ago
|
||||
..............
|
||||
|
||||
Calendar example:
|
||||
..............
|
||||
Original form: *-1/4-5 0/2:00:00
|
||||
Normalized form: *-01/4-05 00/2:00:00
|
||||
Next elapse: Sun 2021-09-05 00:00:00 PST
|
||||
(in UTC): Sat 2021-09-04 16:00:00 UTC
|
||||
From now: 1 month 16 days left
|
||||
..............
|
||||
|
||||
#+end_example
|
||||
|
||||
|
||||
|
||||
|
||||
* Unit templates
|
||||
|
||||
You can create unit templates which is useful for simple services that only requires an argument.
|
||||
@ -178,113 +101,6 @@ WantedBy=default.target
|
||||
|
||||
|
||||
|
||||
* Transient units
|
||||
|
||||
You can create units on-the-go with =systemd-run=.
|
||||
It generates transient unit files.
|
||||
Though, this is oriented around service units, making it useful for one-time configurations and task scheduling.
|
||||
|
||||
Like most systemd-related binaries, this can configure in system- and user-level.
|
||||
|
||||
#+begin_src shell
|
||||
# This will create a user-level service file with the given command as the task.
|
||||
systemd-run --user borgmatic --config emergency-config.yaml --verbose
|
||||
|
||||
# Create a transient timer for the service.
|
||||
systemd-run --user borg-backup@external-drive.service --on-calendar=12:00
|
||||
#+end_src
|
||||
|
||||
The result should give you the generated name of the unit.
|
||||
Then, they can be managed like an ordinary unit.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
* Service management
|
||||
|
||||
One of the functions of the system suite is service management.
|
||||
Like most of the components, it can be used at user-level with their set locations, managing the service daemon, and all.
|
||||
|
||||
Just plop down a service unit file at one of the search paths and you can start managing right away.
|
||||
For more information, see the manual page (i.e., =systemd.service.5=).
|
||||
A summarized version can be found at [[Service configuration]].
|
||||
|
||||
Here's an example of a user service resided as =$HOME/.config/systemd/user/drive-backup.service=.
|
||||
|
||||
#+begin_src ini
|
||||
[Unit]
|
||||
Description=Periodic safety backup for my external drive
|
||||
Documentation=man:borg(1) https://www.borgbackup.org/ https://torsion.org/borgmatic/
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 create
|
||||
ExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 prune
|
||||
ExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 check
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
#+end_src
|
||||
|
||||
You can then start the service with:
|
||||
|
||||
#+begin_src shell :eval no
|
||||
systemctl --user start drive-backup.service
|
||||
#+end_src
|
||||
|
||||
You can also stop it with the =stop= subcommand (e.g., ~systemctl --user stop drive-backup.service~) and restart it with =restart= (e.g., ~systemctl --user restart drive-backup.service~).
|
||||
|
||||
If you want to enable it at startup, you can go with =enable= subcommand.
|
||||
(To disable it, use the =disable= subcommand.)
|
||||
|
||||
#+begin_src shell :eval no
|
||||
systemctl --user enable drive-backup.service
|
||||
#+end_src
|
||||
|
||||
systemd will use the configuration file as-is by the time it is started/enabled.
|
||||
Which means if the config file has been modified after activation, it will not take effect until you restarted it.
|
||||
For this, you can reload the daemon with =daemon-reload= subcommand.
|
||||
But for simpler cases, you can use the =reload= subcommand without fully restarting the daemon.
|
||||
|
||||
#+begin_src shell :eval no
|
||||
systemctl --user reload drive-backup.service
|
||||
|
||||
# You could also use...
|
||||
# systemctl --user daemon-reload
|
||||
# ...if you need a stronger option.
|
||||
#+end_src
|
||||
|
||||
|
||||
** Service configuration
|
||||
|
||||
There are different types of services.
|
||||
|
||||
- The most common type of service is =simple= which considers the unit active after the main process is forked (e.g., =Service.ExecStart=).
|
||||
This is the recommended type for long-running processes.
|
||||
|
||||
- =oneshot= marks the service resolved after the main process exits.
|
||||
Due to the behavior, it will directly go from activating to deactivating instead of active.
|
||||
|
||||
- =exec= considers the service active after the binary has been executed.
|
||||
|
||||
Aside from types, each service may have one or more commands although the behavior is set depending on the type.
|
||||
|
||||
- =ExecStart= which is usually the main command and most services will throw an error if it's missing.
|
||||
All services, unless specified as a =oneshot= service, only have one of these values.
|
||||
|
||||
- =ExecStop= only executes after the main command successfully starts.
|
||||
|
||||
- =ExecStartPre= and =ExecStartPost= gives you additional commands that will be executed before and after the main command, respectively.
|
||||
|
||||
- =ExecStopPre= and =ExecStopPost= is similar to the pre- and post-start commands except for the stop command.
|
||||
|
||||
- =Reload= sets whether the service restarts on fail.
|
||||
Values accepted are =no=, =on-failure=, and =on-success=.
|
||||
|
||||
|
||||
|
||||
|
||||
* Bootloader configuration
|
||||
|
||||
systemd also comes with a bootloader aptly named =systemd-boot= though it only supports UEFI-based firmware.
|
||||
@ -408,3 +224,25 @@ See [[id:941e0a85-1bb4-45be-a729-1b577c7ee317][Command line: journalctl]] for mo
|
||||
#+begin_src shell
|
||||
journalctl --user-unit backup.service --follow --boot
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
|
||||
* Environment directive
|
||||
|
||||
systemd enables setting the environment through environment directives.
|
||||
|
||||
Just like how [[id:c7edff80-6dea-47fc-8ecd-e43b5ab8fb1e][systemd at user-level]], you can set it at user-level.
|
||||
Useful for setting specific environment only for that user.
|
||||
|
||||
It needs a =*.conf= file in one of the load paths (seen from the =environment.d.5= manual page).
|
||||
Keep in mind it does not use the shell and instead makes use of shell-like syntax.
|
||||
|
||||
The following code block is an example of setting Nix-related environment variables to enable desktop integrations.
|
||||
|
||||
#+begin_src
|
||||
# Enable desktop integration with Nix-installed applications.
|
||||
NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
|
||||
PATH=${PATH:+$PATH:}$HOME/.nix-profile/bin
|
||||
XDG_DATA_DIRS=${XDG_DATA_DIRS:+$XDG_DATA_DIRS:}$HOME/.nix-profile/share/
|
||||
#+end_src
|
||||
|
92
notebook/linux.systemd.services.org
Normal file
92
notebook/linux.systemd.services.org
Normal file
@ -0,0 +1,92 @@
|
||||
:PROPERTIES:
|
||||
:ID: cd5f0d04-d9bb-44e8-a0f2-630ea58c1e94
|
||||
:END:
|
||||
#+title: systemd services
|
||||
#+date: 2021-07-19 21:46:52 +08:00
|
||||
#+date_modified: 2021-08-02 11:56:12 +08:00
|
||||
#+language: en
|
||||
|
||||
|
||||
One of the functions of the system suite is service management.
|
||||
Like most of the components, it can be used at user-level with their set locations, managing the service daemon, and all.
|
||||
|
||||
|
||||
|
||||
|
||||
* Service management basics
|
||||
|
||||
Just plop down a service unit file at one of the search paths and you can start managing right away.
|
||||
For more information, see the manual page (i.e., =systemd.service.5=).
|
||||
A summarized version can be found at [[Service configuration]].
|
||||
|
||||
Here's an example of a user service resided as =$HOME/.config/systemd/user/drive-backup.service=.
|
||||
|
||||
#+begin_src ini
|
||||
[Unit]
|
||||
Description=Periodic safety backup for my external drive
|
||||
Documentation=man:borg(1) https://www.borgbackup.org/ https://torsion.org/borgmatic/
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 create
|
||||
ExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 prune
|
||||
ExecStart=%h/.nix-profile/bin/borgmatic --config %h/dotfiles/borgmatic/personal-drive.yaml --verbosity 2 check
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
#+end_src
|
||||
|
||||
You can then start the service with:
|
||||
|
||||
#+begin_src shell :eval no
|
||||
systemctl --user start drive-backup.service
|
||||
#+end_src
|
||||
|
||||
You can also stop it with the =stop= subcommand (e.g., ~systemctl --user stop drive-backup.service~) and restart it with =restart= (e.g., ~systemctl --user restart drive-backup.service~).
|
||||
|
||||
If you want to enable it at startup, you can go with =enable= subcommand.
|
||||
(To disable it, use the =disable= subcommand.)
|
||||
|
||||
#+begin_src shell :eval no
|
||||
systemctl --user enable drive-backup.service
|
||||
#+end_src
|
||||
|
||||
systemd will use the configuration file as-is by the time it is started/enabled.
|
||||
Which means if the config file has been modified after activation, it will not take effect until you restarted it.
|
||||
For this, you can reload the daemon with =daemon-reload= subcommand.
|
||||
But for simpler cases, you can use the =reload= subcommand without fully restarting the daemon.
|
||||
|
||||
#+begin_src shell :eval no
|
||||
systemctl --user reload drive-backup.service
|
||||
|
||||
# You could also use...
|
||||
# systemctl --user daemon-reload
|
||||
# ...if you need a stronger option.
|
||||
#+end_src
|
||||
|
||||
|
||||
* Service configuration
|
||||
|
||||
There are different types of services.
|
||||
|
||||
- The most common type of service is =simple= which considers the unit active after the main process is forked (e.g., =Service.ExecStart=).
|
||||
This is the recommended type for long-running processes.
|
||||
|
||||
- =oneshot= marks the service resolved after the main process exits.
|
||||
Due to the behavior, it will directly go from activating to deactivating instead of active.
|
||||
|
||||
- =exec= considers the service active after the binary has been executed.
|
||||
|
||||
Aside from types, each service may have one or more commands although the behavior is set depending on the type.
|
||||
|
||||
- =ExecStart= which is usually the main command and most services will throw an error if it's missing.
|
||||
All services, unless specified as a =oneshot= service, only have one of these values.
|
||||
|
||||
- =ExecStop= only executes after the main command successfully starts.
|
||||
|
||||
- =ExecStartPre= and =ExecStartPost= gives you additional commands that will be executed before and after the main command, respectively.
|
||||
|
||||
- =ExecStopPre= and =ExecStopPost= is similar to the pre- and post-start commands except for the stop command.
|
||||
|
||||
- =Reload= sets whether the service restarts on fail.
|
||||
Values accepted are =no=, =on-failure=, and =on-success=.
|
86
notebook/linux.systemd.timers.org
Normal file
86
notebook/linux.systemd.timers.org
Normal file
@ -0,0 +1,86 @@
|
||||
:PROPERTIES:
|
||||
:ID: f1b21fc8-86a5-47cd-b3d8-da6ac7a34427
|
||||
:END:
|
||||
#+title: systemd timers
|
||||
#+date: 2021-07-19 21:45:47 +08:00
|
||||
#+date_modified: 2021-08-02 11:55:59 +08:00
|
||||
#+language: en
|
||||
|
||||
|
||||
You can schedule tasks with timers.
|
||||
If systemd is compiled with the feature, it makes cron unnecessary.
|
||||
|
||||
systemd has different ways to denote time.
|
||||
|
||||
- Timespans denote the duration — e.g., =100 seconds=, =5M 3w=.
|
||||
- Timestamps refer to a specific point in time — e.g., =2021-04-02=, =today=, =now=.
|
||||
- Calendar events can refer to more than one point of time — e.g., =*-*-4/2=, =Sun,Wed,Fri *-1/2-1/8=.
|
||||
|
||||
Here's an example of setting a timer for an example backup service.
|
||||
The following timer unit sets it to execute every day at 18:00.
|
||||
|
||||
#+begin_src ini
|
||||
[Unit]
|
||||
Description=A deduplicated backup from my computer
|
||||
Documentation=man:borg(1) https://borgbackup.readthedocs.io/
|
||||
|
||||
[Timer]
|
||||
Unit=borg-backup.service
|
||||
OnCalendar=*-*-* 18:00:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
#+end_src
|
||||
|
||||
If the timer unit is started, this will trigger =borg-backup.service= from the load path.
|
||||
But you can omit it if you named the timer unit file similarly (e.g., =borg-backup.timer= with =borg-backup.service=).
|
||||
|
||||
You can find more information about it from the =systemd.time.5= manual page.
|
||||
Furthermore, systemd has a testing tool for time with ~systemd-analyze {timespan,timestamp,calendar}~.
|
||||
|
||||
#+begin_src shell :eval yes
|
||||
printf "Timespan example:\n"
|
||||
printf "..............\n"
|
||||
systemd-analyze timespan 4000min
|
||||
printf "..............\n\n"
|
||||
|
||||
printf "Timestamp example:\n"
|
||||
printf "..............\n"
|
||||
systemd-analyze timestamp 2021-07-01
|
||||
printf "..............\n\n"
|
||||
|
||||
printf "Calendar example:\n"
|
||||
printf "..............\n"
|
||||
systemd-analyze calendar "*-1/4-5 0/2:00:00"
|
||||
printf "..............\n\n"
|
||||
#+end_src
|
||||
|
||||
#+results:
|
||||
#+begin_example
|
||||
Timespan example:
|
||||
..............
|
||||
Original: 4000min
|
||||
μs: 240000000000
|
||||
Human: 2d 18h 40min
|
||||
..............
|
||||
|
||||
Timestamp example:
|
||||
..............
|
||||
Original form: 2021-07-01
|
||||
Normalized form: Thu 2021-07-01 00:00:00 PST
|
||||
(in UTC): Wed 2021-06-30 16:00:00 UTC
|
||||
UNIX seconds: @1625068800
|
||||
From now: 11h ago
|
||||
..............
|
||||
|
||||
Calendar example:
|
||||
..............
|
||||
Original form: *-1/4-5 0/2:00:00
|
||||
Normalized form: *-01/4-05 00/2:00:00
|
||||
Next elapse: Sun 2021-09-05 00:00:00 PST
|
||||
(in UTC): Sat 2021-09-04 16:00:00 UTC
|
||||
From now: 2 months 4 days left
|
||||
..............
|
||||
|
||||
#+end_example
|
25
notebook/linux.systemd.transient-units.org
Normal file
25
notebook/linux.systemd.transient-units.org
Normal file
@ -0,0 +1,25 @@
|
||||
:PROPERTIES:
|
||||
:ID: a602f900-cdcf-4090-9278-d5926d80eedc
|
||||
:END:
|
||||
#+title: systemd transient units
|
||||
#+date: 2021-08-02 12:01:49 +08:00
|
||||
#+date_modified: 2021-08-02 12:05:06 +08:00
|
||||
#+language: en
|
||||
|
||||
|
||||
You can create units on-the-go with =systemd-run=.
|
||||
Very useful for quickly creating and scheduling one-off services.
|
||||
This tool involves [[id:cd5f0d04-d9bb-44e8-a0f2-630ea58c1e94][systemd services]] and [[id:f1b21fc8-86a5-47cd-b3d8-da6ac7a34427][systemd timers]].
|
||||
|
||||
Like most systemd-related binaries, this can be run at system- and user-level (see [[id:c7edff80-6dea-47fc-8ecd-e43b5ab8fb1e][systemd at user-level]]).
|
||||
|
||||
#+begin_src shell
|
||||
# This will create a user-level service file with the given command as the task.
|
||||
systemd-run --user borgmatic --config emergency-config.yaml --verbose
|
||||
|
||||
# Create a transient timer for the service.
|
||||
systemd-run --user borg-backup@external-drive.service --on-calendar=12:00
|
||||
#+end_src
|
||||
|
||||
The result should give you the generated name of the unit.
|
||||
Then, they can be managed like an ordinary unit.
|
Loading…
Reference in New Issue
Block a user