Skip to content

Is there a software that runs a command at a time that i decide of the day?

Is there a software that runs a command at a time that i decide of the day or of the year?

134 points70 comments
Open on Reddit
About this post
Posted
Archived
Score
134 · 93% up
Kind
Text
ID
juianf

Author

15
posts
45
comments
0
media
View profile

76 comments

unknown author43 hidden

Deleted before we saved it.

223 points

Thank you, i will try cronjob

44 points

As much as people seem to hate systemd, I actually find timers more convenient than cronjobs. Assuming you're using systemd (who isn't these days?) you should check it out.

123 points

Seriously, use systemd timers. Go with your time. You'll rapidly experience their superiority and easy setup compared to cronjob, plus you'll learn how to make systemd unit files in general.

2 points

Be aware that cron is only accurate to ~15min. sorry for any confusion, seems I misremembered something.

-7 points

Systemd timer. It's already in the system and pretty flexible. There's also an arch wiki article about that...

No need to install cron in my opinion.

34 points

Old method: cron or at

New method: systemd.timer or systemd-run

19 points

Wait Cron is considered old-fashioned?

6 points

There's a systemd alternative for everything nowadays, and in my opinion, it is almost always more functional.

8 points

I still use cron - I didn’t even know about systemd timers. Cool!

1 points

Just use cron, it's used all over the place (CircleCi, AWS just off the top of my head) and just works. It's not that difficult to set the frequency exactly how you want it.

6 points

Why is this post having more than 100 upvotes and all the other requests I made barely had 3?

2 points

because it tickles the holy war of oldies from pre-systemd era and systemd hippies.

11 points

I did something like that to join online classes automatically. You can find the post in my account and change it to run a .sh file or whatever you want.

EDIT: Oh and I was using brave browser on linux (ubuntu) so it may vary between different os and browsers

1 points
unknown author

Deleted before we saved it.

1 points

If you are writing your code in Python and want something super simple:

#!/usr/bin/python3
from datetime import time
import timesched

def job(jobid):
    print(f'Job {jobid} called now')

s = timesched.Scheduler()

# Execute job() at 10:30am every work day (not weekends)
s.repeat_on_days('MTWTFss', time(10, 30), 0, job, 1)

# Another job to run every 5 secs
s.repeat(5, 0, job, 2)

# Run in scheduler ..
s.run()

See here.

1 points

Until now I didn't even know about systemd timers, and I've set up plenty of my own systemd unit files.

1 points
unknown author

Deleted before we saved it.

1 points

For all these folks complaining they need to man cron each time, heres a handy template of crontab file ..

#0 */2 * * * /home/archie/.bin/firefox-sync

#23 */6 * * * /home/archie/.bin/recupd.sh

#@reboot echo '~/.bin/firefox-sync' | tee -a ~/.bash_logout ~/.bash_profile >/dev/null

# | | | | | user command

# | | | | weekday (0-6) (Sunday=0)

# | | | month (1-12)

# | | day (0-31)

# | hour (0-23)

# minute (0-59)

1 points

I realized that I am late to the party but I think people should take a second and look at jobber - it's available on Arch and it is written in Go.

It has a really nice list of the jobs you have scheduled, a robust reporting system if a job fails to run, and you can use commands to force a test of your job easily and import and export lists of jobs.

It comes with a status page showing you when all the jobs are going to run based on how you have configured them and letting users who aren't super users configure jobs in their profile that are unique to them without invoking sudo.

-1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.