TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What scripts/cronjobs you have made that made your life generally easier

76 点作者 casper345超过 6 年前
Could be work or life related - trying to get inspiration to write scripts/cronjobs for my own life.

25 条评论

jonny_storm超过 6 年前
I used to back up my friend&#x27;s website over FTP to a git repo. He often would break something and have no way to know what broke or how to fix it.<p>I frequently set up automatic backups of network appliance configurations, route tables, and traceroute results. This is useful for diagnosing sudden problems, as well as taking before and after snapshots when making changes.<p>I collect interesting data, such as kernel version and versions of various services, from hosted web servers my clients run.<p>I collect data at regular intervals when investigating a sporadic, chronic trouble event to help me identify correlations and test hypotheses.<p>I collect BGP and traceroute data at regular intervals from route servers to identify important changes and trends in Internet routing for specific prefixes.<p>I used to collect IDS signatures in a git repo to track updates, but I eventually moved this to GitLab.<p>I regularly run a watchdog script to check for, alert on, and attempt to mitigate low disk space and other such conditions.<p>Hope this helps!
indentit超过 6 年前
I listen to the same radio station on my commute to&#x2F;from work, and to avoid needing to use Shazam etc., I wrote a script which parses the radio station&#x27;s &quot;now playing&quot; web page and logs it to a file every 2 minutes (if the song is different from at the last run). Then I can more easily find&#x2F;remember songs I liked and see trends etc.
评论 #18178360 未加载
评论 #18178114 未加载
tedmiston超过 6 年前
1. A script that opens all of my morning apps and browser tabs in one command.<p>2. I make a run.sh script in every project that I add to my git exclude, so whether it&#x27;s a Go app, Python app, Node app, makefiles, Docker, ..., no matter what I can go into any project and run this script to start it. Then I add an alias in my bash profile so I just type &quot;r&quot; to .&#x2F;run.sh. For more complicated apps, I generalize this to have a build.sh, deploy.sh, etc.
评论 #18179319 未加载
评论 #18178719 未加载
billwear超过 6 年前
I have rewritten the BSD calendar app in every language I can get my hands on, from Perl to Go to Emacs Lisp to.... It isn&#x27;t that I want a calendar app, but it has helped me to develop strong fluency in porting code from one language to another, both at work and in my side projects.
评论 #18179238 未加载
评论 #18179575 未加载
snowwrestler超过 6 年前
I used to host a bunch of Wordpress and Drupal sites on Linux servers. Properly setting file and directory permissions is a huge part of keeping those CMSs secure. The defaults are bad and there is a ton of horrible advice online in the form of troubleshooting threads with responses like &quot;I made the error go away by setting everything to 777!&quot;<p>So I wrote two shell scripts (one for each CMS) that could be easily customized for each site. I ran it by hand whenever we did a deployment, and also set it to run every hour in crontab. That way even if someone changed the permissions away from safe (by accident or maliciously), they would revert to safe pretty quickly.<p>I&#x27;ve since moved all those sites to WP Engine and Pantheon, so now the directory permissions are someone else&#x27;s problem. :-)
评论 #18182237 未加载
mikro2nd超过 6 年前
The one that &quot;switches off&quot; all internet access from 08h00 to 14h00 has done wonders for my productivity (in a positive way!)
评论 #18182031 未加载
评论 #18177991 未加载
p0d超过 6 年前
Cron job every two mintues on my raspberry pi to switch a relay on&#x2F;off depending on the temperature in my shed.<p>Relay is attached to a 500w heater and 4 old computer fans blowing the hot air at my feet.
troyvit超过 6 年前
My work uses google calendars but the calendar reminders aren&#x27;t enough for me to make meetings (and I don&#x27;t look at my phone for calendar alerts), so I use cron combined with gcalcli (<a href="https:&#x2F;&#x2F;github.com&#x2F;insanum&#x2F;gcalcli" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;insanum&#x2F;gcalcli</a>) to give me desktop popups using kdialog for meeting reminders. One at 15 minutes, one at 10 minutes, one at 5 minutes, and one at 1 minute. I now make most meetings!<p>&#x2F;usr&#x2F;bin&#x2F;gcalcli --calendar &#x27;[my calendar]&#x27; --detail_location remind 10 &#x27;&#x2F;path&#x2F;to&#x2F;alertscript.sh &quot;%s&quot;&#x27;<p>where alertscript.sh just calls kdialog with the message describing the meeting.
decasteve超过 6 年前
A couple of life-related ones that I regularly use:<p>bank csv to sqlite: stores all of my banking transactions in sqlite.<p>high-tide-calendar-beach: Uses XTide to create a csv of high&#x2F;low tide times for a local beach and then converts it to an ics calendar that gets copied to a server where my calendar apps read it. (The local beach is inaccessible at high hide)
评论 #18188845 未加载
评论 #18190661 未加载
ibnishak超过 6 年前
I have an fcron[1] job that will perform a mysqldump, encrypt the resultant file using an incremental file backup program called borg[2], rclone the same to a remote site and log the time of the last run to a text file. I do the same for my dotfiles too, which is collected inside a single folder and make use of stow[3]<p>[1] <a href="http:&#x2F;&#x2F;fcron.free.fr&#x2F;" rel="nofollow">http:&#x2F;&#x2F;fcron.free.fr&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;borgbackup.readthedocs.io&#x2F;en&#x2F;stable&#x2F;" rel="nofollow">https:&#x2F;&#x2F;borgbackup.readthedocs.io&#x2F;en&#x2F;stable&#x2F;</a><p>[3] <a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;stow&#x2F;manual&#x2F;stow.html" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;stow&#x2F;manual&#x2F;stow.html</a>
flukus超过 6 年前
The best ones have been auto complete scripts for more mundane ones like in this tutorial: <a href="https:&#x2F;&#x2F;iridakos.com&#x2F;tutorials&#x2F;2018&#x2F;03&#x2F;01&#x2F;bash-programmable-completion-tutorial.html" rel="nofollow">https:&#x2F;&#x2F;iridakos.com&#x2F;tutorials&#x2F;2018&#x2F;03&#x2F;01&#x2F;bash-programmable-...</a> .<p>One example I deal with often is interacting with third party systems. I had scripts to simulate them for ages but had to copy the values to generate the correct files from the UI&#x2F;database. Now the auto-complete scripts look up the values in the database directly so I can usually just use tab completion.
codegeek超过 6 年前
I love writing shell&#x2F;bash scripts to automate stuff on our servers. Some little things I have done:<p>- Wrote a script to take automatic backups from server to AWS S3 bucket and add that script to a cron.<p>- Wrote an all-in-one script to install&#x2F;configure&#x2F;setup WordPress on a barebone VPS server using a LEMP stack along with LetsEncrypt SSL. Fully automated but you need to have a domain pointing to the server for letsencrypt. Once you have a basic Ubuntu server provisioned, this script takes care of everything else.<p>- Playing with a simple script that sends basic server stats to an API endpoint (I know I could use monitoring tools but where is the fun in that :))
cstrasen超过 6 年前
A tiny script in my google account that regularly scans the next week and auto-rejects meetings invites when they don&#x27;t have an agenda and a goal specified. It then emails the meeting owner with a request to change.<p>PM me for the code.
评论 #18184353 未加载
Pyrodogg超过 6 年前
Auto purging my downloads folder with a scheduled task.<p>I received a new laptop for work this spring and was determined to make my downloads folder strictly temp storage, but loathed putting any sort of manual work into it periodically.<p>I have a small powershell script which moves all files in downloads older than X days into a &#x27;dumpster&#x27; folder (not straight to recycle bin), and then all dumpster files older than Y days, into the recycle bin.<p>Scheduled in the task manager to run daily. And for the first time, I have a tame downloads folder.
anotheryou超过 6 年前
browser script: one that shows me duckduckgo &quot;bangs&quot; for any site I&#x27;m on (search keywords that forward directly to a 3rd party search)<p>browser script for work (web stuff): auto fill for creating test accounts, indicating which server I&#x27;m on, injecting little shortcut links here and there.<p>With help the windows utility shareX I can paste markdown via a shortcut and get a sharable link with html on my server back in to the clipboard.<p>not mine but great: I saw someone having readmes and todos in project folders and than aggregating them
_mrmnmly超过 6 年前
I&#x27;ve created a script that installs all necessary stuff for me if I would need to reinstall my system - saved it on remote repo to just download &amp; run it after fresh system is installed: <a href="https:&#x2F;&#x2F;github.com&#x2F;lukaszkups&#x2F;linux-installation-script" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lukaszkups&#x2F;linux-installation-script</a> (it might be now pretty outdated)
stockkid超过 6 年前
I wrote a cron job to send me weekly email digest of things I learn. During the week days, I use my open source program [0] to quickly write down things as I learn them. On Friday, I receive a email digest to refresh my memory.<p>This method put spaced repetition on an autopilot and helped me learn more.<p>[0] - <a href="https:&#x2F;&#x2F;github.com&#x2F;dnote&#x2F;cli" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dnote&#x2F;cli</a>
mbrock超过 6 年前
I used my bash WebDriver tool (<a href="https:&#x2F;&#x2F;github.com&#x2F;mbrock&#x2F;wd" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mbrock&#x2F;wd</a>) to write a script that logs into my online bank in a browser window, prompting me in the terminal for the one-time code from the little gadget, because for some reason I find clicking around in the bank website so truly horrible.
评论 #18179869 未加载
Noumenon72超过 6 年前
AutoHotKey is the big help here. Shortcuts instead of hunting for files, shortcuts instead of repetitive menu commands, remapping keys to do screenshots or launch KDiff or whatever. Like for example, I set one up that only applies to Outlook and applies a monospace style to the selected text so it looks like code. That was a bunch of clicks before and now it&#x27;s just Ctrl+Q.
billconan超过 6 年前
every time my dynamic ips change (work machines), I send a message with the latest ips to my slack, so that when I vpn+ssh, I know the ips.
blacksmith_tb超过 6 年前
I made a pseudo-grandfather clock with an RPi connected to a $1 motor controller + servo, cronjobs call a little python script that moves the servo to strike a long chime N times on the hour (and I have it scheduled to ring during times of the day when I am usually home and awake, and otherwise keep quiet).
apoorvam6超过 6 年前
- Periodically delete postgres table records older than (x) days and also, move the records older than (y) days to cold storage.<p>- Script&#x2F;Bot, to download my favourite songs searching from multiple sources given its name as input.
extremum134超过 6 年前
In android terminal, I made a script which would set a nice coloured PS1, a few handy aliases, shell functions &amp; PATH extensions upon app startup. BTW command line on android is very useful.
m-p-3超过 6 年前
A script sending an IFTTT push message when a torrent download starts or finished downloading
kspy超过 6 年前
cleanup psql logs older than (x) amt of days on production instances