Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

cron

How can I programmatically create a new cron job?

November 20, 2022 by Tarik

The best way if you’re running as root, is to drop a file into /etc/cron.d if you use a package manager to package your software, you can simply lay down files in that directory and they are interpreted as if they were crontabs, but with an extra field for the username, e.g.: Filename: /etc/cron.d/per_minute Content: … Read more

Categories linux Tags cron, linux, unix Leave a comment

What is the curl error 52 “empty reply from server”?

November 18, 2022 by Tarik

This can happen if curl is asked to do plain HTTP on a server that does HTTPS. Example: $ curl http://google.com:443 curl: (52) Empty reply from server

Categories curl Tags cron, curl Leave a comment

How to get CRON to call in the correct PATHs

November 15, 2022 by Tarik

I used /etc/crontab. I used vi and entered in the PATHs I needed into this file and ran it as root. The normal crontab overwrites PATHs that you have set up. A good tutorial on how to do this. The systemwide cron file looks like this: This has the username field, as used by /etc/crontab. … Read more

Categories linux Tags cron, linux, path Leave a comment

How to write a cron that will run a script every day at midnight?

November 14, 2022 by Tarik

Here’s a good tutorial on what crontab is and how to use it on Ubuntu. Your crontab line will look something like this: 00 00 * * * ruby path/to/your/script.rb (00 00 indicates midnight–0 minutes and 0 hours–and the *s mean every day of every month.) Syntax: mm hh dd mt wd command mm minute … Read more

Categories ubuntu Tags cron, ubuntu Leave a comment

Run cron job only if it isn’t already running

November 11, 2022 by Tarik

Use flock. It’s new. It’s better. Now you don’t have to write the code yourself. Check out more reasons here: https://serverfault.com/a/82863 /usr/bin/flock -n /tmp/my.lockfile /usr/local/bin/my_script

Categories linux Tags bash, cron, linux, watchdog Leave a comment

How to specify in crontab by what user to run script? [closed]

October 21, 2022 by Tarik

Instead of creating a crontab to run as the root user, create a crontab for the user that you want to run the script. In your case, crontab -u www-data -e will edit the crontab for the www-data user. Just put your full command in there and remove it from the root user’s crontab.

Categories ubuntu Tags cron, crontab, ubuntu Leave a comment

How do I create a crontab through a script

October 16, 2022 by Tarik

Here’s a one-liner that doesn’t use/require the new job to be in a file: (crontab -l 2>/dev/null; echo “*/5 * * * * /path/to/job -with args”) | crontab – The 2>/dev/null is important so that you don’t get the no crontab for username message that some *nixes produce if there are currently no crontab entries.

Categories linux Tags cron, crontab, linux, shell, ubuntu Leave a comment

How to run cron once, daily at 10pm [closed]

October 11, 2022 by Tarik

It’s running every minute of the hour 22 I guess. Try the following to run it every first minute of the hour 22: 0 22 * * * ….

Categories bash Tags bash, cron, scheduled-tasks, system Leave a comment

Crontab Day of the Week syntax

October 5, 2022 by Tarik

0 and 7 both stand for Sunday, you can use the one you want, so writing 0-6 or 1-7 has the same result. Also, as suggested by @Henrik, it is possible to replace numbers by shortened name of days, such as MON, THU, etc: 0 – Sun Sunday 1 – Mon Monday 2 – Tue … Read more

Categories linux Tags cron, crontab, linux, sysadmin Leave a comment

Test a weekly cron job [closed]

October 5, 2022 by Tarik

Just do what cron does, run the following as root: run-parts -v /etc/cron.weekly … or the next one if you receive the “Not a directory: -v” error: run-parts /etc/cron.weekly -v Option -v prints the script names before they are run.

Categories linux Tags cron, debian, linux Leave a comment
Older posts
Newer posts
← Previous Page1 … Page18 Page19 Page20 Page21 Next →

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa