What are Crontabs & Watchdogs?

Olga NedelcuOlga Nedelcu
1 min read

Crontab and watchdog?

So, for a service, we had the idea of putting a cron tab to execute a script, essentially like a watchdog.

Crontab is a command-line utility in Unix-like operating systems that is used to schedule commands to be executed periodically at fixed times, dates, or intervals.

It allows users to automate repetitive tasks by defining the schedule for when specific commands or scripts should run.

Every day, for example, it would be triggered, and the logs would be written into another file (we chose the location of the file).

Why?

It was the simplest solution for our program and quite fast*.*

Command: crontab -e (using iTerm as a shell)

It will get you to a vim editor file to input your lines of code.

crontab -e

Here, we execute @hourly and then execute the do.sh file in the Docker user; forwarding the logs to the do.log file.

The 2>&1 redirects Channel 2 (standard Error) to the same place, which, in this context, is Channel 1 (standard Output).

The first time I heard about this, I understood nothing; it was like I was listening to Chinese 🙈.

But now, it’s more and more understandable; especially after seeing it being executed.

It’s a service that is quite helpful on a Linux machine

0
Subscribe to my newsletter

Read articles from Olga Nedelcu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Olga Nedelcu
Olga Nedelcu

I'm a community-minded engineer based in Berlin, originally from Romania, and I grew up in sunny Spain. I combine the best of both communication and technical skills, with experience in both the engineering world and the business side of things. I'm proficient in a wide range of technologies like JavaScript, React.js, Redux, TypeScript, Node.js, HTML/CSS, Styled Components, SASS, and REST APIs. I love going beyond just writing code by sharing knowledge with my team through Communities of Practice (COPs), Employee Resource Groups (ERGs), and detailed technical documentation. My main interests are in frontend frameworks, web standards, accessibility (A11y), and Clean Code. My passion for programming started in high school when I built my first website. Since 2019, I've been working as a professional software developer, thriving in agile and iterative environments. Nearly five years later, I'm still excited to dive into code and collaborate with my colleagues. I'm very open and friendly, good at turning technical concepts into easy-to-understand information for everyone.