mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-13 22:30:37 +08:00
translated
This commit is contained in:
parent
3b85cee88b
commit
aff7466757
@ -1,78 +0,0 @@
|
||||
[#]: subject: "My favorite open source tool for using crontab"
|
||||
[#]: via: "https://opensource.com/article/22/5/cron-crontab-ui"
|
||||
[#]: author: "Kevin Sonney https://opensource.com/users/ksonney"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
My favorite open source tool for using crontab
|
||||
======
|
||||
Crontab-ui is a web frontend written in Node.js that helps manage the crontab file.
|
||||
|
||||
![Woman using laptop concentrating][1]
|
||||
(Image by Mapbox Uncharted ERG, [CC-BY 3.0 US][2])
|
||||
|
||||
*Automation is a hot topic right now. In my day job as a site reliability engineer (SRE), part of my remit is to automate as many repeating tasks as possible. But how many of do that in our daily, not-work, lives? This year, I am focused on automating away the toil so that we can focus on the things that are important.*
|
||||
|
||||
One of the earliest things I learned about as a fledgling systems administrator was `cron`. Cron is used far and wide to do things like rotate logs, start and stop services, run utility jobs, and more. It is available on almost all Unix and Linux systems, and is something every sysadmin I know uses to help manage services and servers. Cron can run any console application or script automatically, which makes it very, very flexible.
|
||||
|
||||
![Image of a Crontab][3]
|
||||
(Image by: Kevin Sonney, CC BY-SA 4.0)
|
||||
|
||||
I have used cron to fetch email, run filtering programs, make sure a service is running, interact with online games like Habitica, and a lot more.
|
||||
|
||||
### Using cron the traditional way
|
||||
|
||||
To get started with cron, you can simply type `crontab -e` at the command line to open up an editor with the current `crontab` (or “cron table”) file for yourself (if you do this as root, you get the system crontab). This is where the job schedule is kept, along with when to run things. David Both has written [extensively][4] on the format of the file and how to use it, so I'm not going to cover that here. What I am going to say is that for new users, it can be a bit scary, and getting the timing set up is a bit of a pain.
|
||||
|
||||
### Introducing crontab-ui
|
||||
|
||||
There are some fantastic tools out there to help with this. My favorite is [crontab-ui][5], a web frontend written in Node.js that helps manage the crontab file. To install and start `crontab-ui` for personal use, I used the following commands.
|
||||
|
||||
```
|
||||
# Make a backup
|
||||
crontab -l > $HOME/crontab-backup
|
||||
# Install Crontab UI
|
||||
npm install -g crontab-ui
|
||||
# Make a local database directory
|
||||
mkdir $HOME/crontab-ui
|
||||
# Start crontab-ui
|
||||
CRON_DB_PATH=$HOME/crontab-ui crontab-ui
|
||||
```
|
||||
|
||||
Once this is done, simply point your web browser at`http://localhost:8000` and you'll get the crontab-ui web interface. The first thing to do is click “Get from Crontab” to load any existing jobs you may have. Then click **Backup** so that you can roll back any changes you make from here on out.
|
||||
|
||||
![Image of Crontab-UI][6]
|
||||
(Image by: Kevin Sonney, CC BY-SA 4.0)
|
||||
|
||||
Adding and editing cron jobs is very simple. Add a name, the full command you want to run, and the time (using cron syntax), and save. As a bonus, you can also capture logs, and set up the mailing of job status to your email of choice.
|
||||
|
||||
When you're finished, click**Save to Crontab**.
|
||||
|
||||
I personally really love the logging feature. With crontab-ui, you can view logs at the click of a button, which is useful when troubleshooting.
|
||||
|
||||
One thing I do recommend is to not run crontab-ui all the time, at least not publically. While it does have some basic authentication abilities, it really shouldn't be exposed outside your local machine. I don't need to edit my cron jobs frequently (anymore), so I start and stop it on demand.
|
||||
|
||||
Try crontab-ui the next time you need to edit your crontab!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/5/cron-crontab-ui
|
||||
|
||||
作者:[Kevin Sonney][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/ksonney
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/sites/default/files/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png
|
||||
[2]: https://creativecommons.org/licenses/by/3.0/us/
|
||||
[3]: https://opensource.com/sites/default/files/2022-04/Day01-1.png
|
||||
[4]: https://opensource.com/article/17/11/how-use-cron-linux
|
||||
[5]: https://opensource.com/%5Bhttps%3A//github.com/alseambusher/crontab-ui%5D%28https%3A//github.com/alseambusher/crontab-ui%29
|
||||
[6]: https://opensource.com/sites/default/files/2022-04/Day01-2.png
|
@ -0,0 +1,78 @@
|
||||
[#]: subject: "My favorite open source tool for using crontab"
|
||||
[#]: via: "https://opensource.com/article/22/5/cron-crontab-ui"
|
||||
[#]: author: "Kevin Sonney https://opensource.com/users/ksonney"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
我最喜欢的使用 crontab 的开源工具
|
||||
======
|
||||
crontab-ui 是一个用 Node.js 编写的 Web 前端,帮助管理 crontab 文件。
|
||||
|
||||
![Woman using laptop concentrating][1]
|
||||
(图片提供:Mapbox Uncharted ERG,[CC-BY 3.0 US][2])
|
||||
|
||||
*自动化是目前的一个热门话题。在我作为网站可靠性工程师(SRE)的日常工作中,我的部分职责是将尽可能多的重复性任务自动化。但是,有多少人在我们的日常非工作生活中这样做呢?今年,我专注于将劳作自动化,以便我们可以专注于重要的事情。*
|
||||
|
||||
作为一个初出茅庐的系统管理员,我最早了解的东西之一是 “cron”。cron 被广泛用于做一些事情,如轮换日志、启动和停止服务、运行程序作业等等。它在几乎所有的 Unix 和 Linux 系统中都可用,而且是我认识的每个系统管理员用来帮助管理服务和服务器的东西。cron 可以自动运行任何控制台应用或脚本,这使得它非常、非常灵活。
|
||||
|
||||
![Image of a Crontab][3]
|
||||
(图片提供:Kevin Sonney,CC BY-SA 4.0)
|
||||
|
||||
我已经用 cron 来获取电子邮件,运行过滤程序,确保服务正在运行,与 Habitica 等在线游戏互动等。
|
||||
|
||||
### 以传统方式使用 cron
|
||||
|
||||
要开始使用 cron,你可以简单地在命令行输入 `crontab -e`,为自己打开一个带有当前 `crontab`(或 “cron table”)文件的编辑器(如果你以 root 身份这样做,你会得到系统 crontab)。这是保存作业计划的地方,以及何时运行。David Both 已经写了[大量][4]关于该文件的格式和如何使用它的文章,所以我不打算在这里介绍。我要说的是,对于新用户来说,这可能有点吓人,而且设置时间有点痛苦。
|
||||
|
||||
### 介绍 crontab-ui
|
||||
|
||||
有一些奇妙的工具可以帮助解决这个问题。我最喜欢的是 [crontab-ui][5],这是一个用 Node.js 编写的 Web 前端,可以帮助管理 crontab 文件。为了安装和启动 `crontab-ui` 供个人使用,我使用了以下命令。
|
||||
|
||||
```
|
||||
# Make a backup
|
||||
crontab -l > $HOME/crontab-backup
|
||||
# Install Crontab UI
|
||||
npm install -g crontab-ui
|
||||
# Make a local database directory
|
||||
mkdir $HOME/crontab-ui
|
||||
# Start crontab-ui
|
||||
CRON_DB_PATH=$HOME/crontab-ui crontab-ui
|
||||
```
|
||||
|
||||
完成这些后,只需将你的网络浏览器指向 `http://localhost:8000`,你就会得到 crontab-ui 的网络界面。要做的第一件事是点击 “Get from Crontab”,加载你可能有的任何现有作业。然后点击**备份**,这样你就可以回滚你所做的任何修改。
|
||||
|
||||
![Image of Crontab-UI][6]
|
||||
(图片提供:Kevin Sonney,CC BY-SA 4.0)
|
||||
|
||||
添加和编辑 cron 作业是非常简单的。添加一个名称,你想运行的完整命令,以及时间(使用 cron 语法),然后保存。另外,你还可以捕获日志,并设置将工作状态邮寄到你选择的电子邮箱。
|
||||
|
||||
完成后,点击 **Save to Crontab**。
|
||||
|
||||
我个人非常喜欢日志记录功能。有了 crontab-ui,你可以通过点击一个按钮来查看日志,这在排除故障时非常有用。
|
||||
|
||||
我推荐的一件事是不要一直运行 crontab-ui,至少不要公开运行。虽然它确实具有一些基本的身份验证功能,但它不应该暴露在你的本地机器之外。我不需要经常(现在)编辑我的 cron 作业,所以我可以按需启动和停止它。
|
||||
|
||||
下次你需要编辑你的 crontab 时,可以试试 crontab-ui!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/5/cron-crontab-ui
|
||||
|
||||
作者:[Kevin Sonney][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/ksonney
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/sites/default/files/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png
|
||||
[2]: https://creativecommons.org/licenses/by/3.0/us/
|
||||
[3]: https://opensource.com/sites/default/files/2022-04/Day01-1.png
|
||||
[4]: https://opensource.com/article/17/11/how-use-cron-linux
|
||||
[5]: https://opensource.com/%5Bhttps%3A//github.com/alseambusher/crontab-ui%5D%28https%3A//github.com/alseambusher/crontab-ui%29
|
||||
[6]: https://opensource.com/sites/default/files/2022-04/Day01-2.png
|
Loading…
Reference in New Issue
Block a user