This is how you do Cronjobs. (404 MEME NOT FOUND)

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ก.ย. 2024
  • lukesmith.xyz

ความคิดเห็น • 79

  • @cosmojg
    @cosmojg 6 ปีที่แล้ว +128

    You can do:
    sudo systemctl enable --now program
    Instead of:
    sudo systemctl enable program
    sudo systemctl start program
    Less keystrokes, more efficiency.

    • @rm_rfasterisk
      @rm_rfasterisk 5 ปีที่แล้ว +14

      I've been using linux for almost 4 years now. I feel stupid for not knowing this and blessed to know this thing exists. 11/10 for you, fellow internet stranger.

    • @VtDmhD
      @VtDmhD 4 ปีที่แล้ว +8

      Depending on your password legnth, omitting sudo may save even more keystrokes, systemctl will ask for root password in such case.

    • @paymonsharif9234
      @paymonsharif9234 3 ปีที่แล้ว +1

      This version of systemctl only runs on linux so its irrelevant to everybody except gnutard loonix lusers.

    • @4cps777
      @4cps777 2 ปีที่แล้ว +3

      @@paymonsharif9234 This version of systemctl only runs on systemd-linuxd so it's irrelevant to everybody except people who think that PID1 should play sound, do DNS, use Google's internal time servers to look up a (wrong) time, crash the kernel when booted in debug mode, include a calendar that can break the entire system, etc.

  • @marcussmithwick6326
    @marcussmithwick6326 6 ปีที่แล้ว +82

    Thank you Kanye, very cool!

  • @pcfreak1992
    @pcfreak1992 6 ปีที่แล้ว +37

    Just to clarify, the "/15" notation is not a modulo action. I made that mistake myself and wondered why a cronjob ran, when it wasn't supposed to. In reality, the notation means the value before the slash plus a multiple of the number after it. If the result equals the current time's value, it's a match.
    For example, */2 in the month column is 1,3,5,7,9,11, since months are numbered 1-12 in cron.
    Source: `man 5 crontab`

    • @thereddrob
      @thereddrob 4 ปีที่แล้ว +5

      months are 1-12 but days of the week are 0-6? Oof

    • @reijerboodt8715
      @reijerboodt8715 3 ปีที่แล้ว

      That is exactly a modulo action! What you describe is that 'a/b' matches precisely those times x which are equal to a (modulo b).

  • @dalekteta9852
    @dalekteta9852 6 ปีที่แล้ว +35

    Well, archlinux comes with systemd timers. They can do the same work. What are the advantages of installing separate crone manager?

    • @HikloLime
      @HikloLime 6 ปีที่แล้ว +6

      Unix philosophy i guess

    • @dachd
      @dachd 6 ปีที่แล้ว +17

      familiarity, I hate timers as they have weird syntax and they spread on multiple files.
      crontab is just single file.
      I've seen a wrapper program somwhere that emulates crontab with systemd timers.

    • @vison360
      @vison360 6 ปีที่แล้ว +4

      Timers works fine but you need to create two units for each task - timer and oneshot service.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 6 ปีที่แล้ว +6

      The nice thing about systemd is that it means user files are kept in the user area, instead of being in /var/spool/cron. Much tidier.

    • @thelinuxcolonel
      @thelinuxcolonel 6 ปีที่แล้ว +13

      whoa this guy uses systemd unironically

  • @oxodao
    @oxodao 6 ปีที่แล้ว +12

    Neat idea to autodownload updates, I never do them because I dont have fiber at home. I'd never thought of this

    • @Motolav
      @Motolav 6 ปีที่แล้ว +3

      Nathan J I wouldn't want to automate system updates on any OS like Arch in case an update is problematic/system breaking or requires intervention.
      The autodownload script is pretty smart tho.

    • @AnastasisGrammenos
      @AnastasisGrammenos 6 ปีที่แล้ว +1

      pacman -Syuw man!

  • @Gokuroro
    @Gokuroro 6 ปีที่แล้ว +3

    Thanks for this post. I always wanted to look into cron, but from the random stuff I looked I always thought it was too much to work to be worth it. Didn't think it was this simple.

  • @iLeev1
    @iLeev1 6 ปีที่แล้ว +14

    Your console text is hard to see on low brightness

  • @mina86
    @mina86 5 ปีที่แล้ว +2

    6:20 - this is a very strange way to write it. Why note:
    DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus /home/luke/.config/mutt/etc/mailsync.sh

  • @lukerb52
    @lukerb52 4 ปีที่แล้ว +3

    They should just put your channel on the Arch WIki

  • @dillon4321
    @dillon4321 5 ปีที่แล้ว +2

    Do you use lock files in your cron scripts to prevent race conditions or the same script running multiple instances? Can be useful when jobs both execute very frequently, and may take some time to finish.

  • @sethcenterbar
    @sethcenterbar 6 ปีที่แล้ว +2

    If you're wondering how to run something other than bash from cron (maybe python, for example), use this syntax
    */10 * * * * /usr/bin/python script.py
    OR
    put the following at the top of your python file
    #! /usr/bin/python
    This was confusing to me at first.

  • @williamevans6830
    @williamevans6830 6 ปีที่แล้ว +3

    Excellent demo of Cron jobs. Thanks again.

  • @mibdev
    @mibdev 6 ปีที่แล้ว +2

    Ah, thank you.
    I've wanted to know more about this, but haven't been bothered to research it.

  • @akinozgen
    @akinozgen 4 ปีที่แล้ว

    that eval "export DBUS" shit saved my day.

  • @awk4722
    @awk4722 6 ปีที่แล้ว +24

    Growing out the beard to achieve rms neckbeard greatness?

  • @rasix86
    @rasix86 6 ปีที่แล้ว

    offtopic: mpd has an auto_update option in mpd.conf, which will find new songs based on mtime. That is done utilizing inotify so no polling is required. Also: Is that a lightning that flashes when you close a window? How have you done that?

  • @cuttlefishn.w.2705
    @cuttlefishn.w.2705 3 ปีที่แล้ว

    You forgot to mention that "day of week" doesn't cooperate with "day of month" the way you would expect, so you can't schedule something to run biweekly.

  • @KyleLanmon
    @KyleLanmon 6 ปีที่แล้ว +2

    Does pacman delete the updates if you do not want to install them? Seems like it could fill your disk if not.

    • @LukeSmithxyz
      @LukeSmithxyz  6 ปีที่แล้ว +1

      No it doesn't, but if you're worried about disk space, just have `pacman -Sc --noconfirm` run as a cronjob every once in a while to clean out the cache ;-)

    • @AnastasisGrammenos
      @AnastasisGrammenos 6 ปีที่แล้ว +1

      Pacman doesn't delete downloaded packages on it's own, so since you weren't aware of this, you should probably clean /var/cache/pacman/pkg a bit. I once found a command that deleted everything but the last 2 versions of each package (In case you need downgrade) but can't remember it. Google it tho!

  • @wonderingwhy6410
    @wonderingwhy6410 5 ปีที่แล้ว

    Aren't these utilities mandatory for posix? Does that make archlinux not posix compliant?

  • @jan_harald
    @jan_harald 5 ปีที่แล้ว

    crons are almost the same...
    for example anacron is different from the ole' standard cron...
    syntaxially and functionally they're same tho

  • @MoreChannelNoise
    @MoreChannelNoise 5 ปีที่แล้ว

    So you have to enable the cron service, then you sudo systemctl start cronie, but do you have to do the second command to start cronie on every startup and what would be a good way to do that?

  • @aayushbajaj2260
    @aayushbajaj2260 2 ปีที่แล้ว

    just learned about locate and updatedb today. I reckon it'd be beautiful with fzf

  • @hannesthiersen8170
    @hannesthiersen8170 6 ปีที่แล้ว +2

    What happens when you suspend or shutdown (forcefully interrupting) while one of the cronjobs are running?

    • @gaurangshukla8235
      @gaurangshukla8235 4 ปีที่แล้ว

      If that job was writing something in file there is chance of that file getting corrupted.

  • @jonathanwarner1844
    @jonathanwarner1844 5 ปีที่แล้ว

    There is a Linux distro that doesn't come with cron?

  • @ooze9808
    @ooze9808 3 ปีที่แล้ว

    I think i paid for a cronjob once in a trailerpark.

  • @rumar4u
    @rumar4u 6 ปีที่แล้ว

    I have a Script for autoupdate, autoremove, autoclean, etc in Arch and another Ubuntu PC. With this example I can run that script more frequently automatically, but how to reboot if it needs it after upgrading packages...? Thanks in advance

    • @xXhotshot55Xx
      @xXhotshot55Xx 5 ปีที่แล้ว

      You shouldn't be automatically updating/installing packages in case their is something in the update that could cause a major breakage.

  • @psylosryummy
    @psylosryummy 6 ปีที่แล้ว +8

    The virgin cron job vs the chad systemd timer

  • @SalarKalantari
    @SalarKalantari 6 ปีที่แล้ว +2

    For the love of god I don't understand, why don't you move to Gentoo alrealy? Come to the dark side it's way more fun.

    • @AnastasisGrammenos
      @AnastasisGrammenos 6 ปีที่แล้ว +3

      Correct me if I am wrong, but since you compile everything urself, you would need a better laptop than an old thinkpad.

    • @AnastasisGrammenos
      @AnastasisGrammenos 6 ปีที่แล้ว +1

      I recently had to compile gcc 7 on an old centOS server and it almost took a day. And it was more powerful than the laptop I was sshing there with.

    • @SalarKalantari
      @SalarKalantari 6 ปีที่แล้ว +2

      You should do some GCC optimization, to be able to compile faster. Even my 15 years old desktop PC compile faster than that.

  • @pZq_
    @pZq_ 6 ปีที่แล้ว

    G R E A T ! More of it!

  • @fuanka1724
    @fuanka1724 6 ปีที่แล้ว

    Cronie? How about regular systemd timers?

  • @dmsalomon
    @dmsalomon 6 ปีที่แล้ว

    I think */15 means 15 times an hour (every 4 minutes), not every 15 minutes.

  • @daggawagga
    @daggawagga 6 ปีที่แล้ว

    Nice

  • @TheFlyingMCFish
    @TheFlyingMCFish 6 ปีที่แล้ว +3

    How to use cronjobs on Arch Linux? You don't, just use systemdtimers, no extra software needed and yes, they got a lot of advantages.

    • @desktorp
      @desktorp 6 ปีที่แล้ว +5

      typical turd polishing observation from a systemd pusher

    • @TheFlyingMCFish
      @TheFlyingMCFish 6 ปีที่แล้ว +1

      david esktorp okay I must admit that I'm kind of disappointed not getting a single argument for using a Cron-Manager instead of the software I already got.

    • @desktorp
      @desktorp 6 ปีที่แล้ว +5

      spoken like a true systemd aficionado; _"I'm kind of disappointed not getting a single argument"_ Did it even occur to you that this video is not about Arch and therefor, not systemd-specific? Did you even read the title? It says _This is how you do Cronjobs._ It does not say _This is how you do Cronjobs, on Arch Linux._ It definitely does not say _This is the reason to use Cron instead of systemd for scheduled tasks._
      The irony of your reasoning here is a really impressive feat of mental gymnastics. I'm continually amazed how fanatics can take an argument against using systemd and twist it in to an argument supporting systemd. *(..instead of the software I already got.)*

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 6 ปีที่แล้ว +1

      The whole cron concept is showing its age.

    • @propellergarage
      @propellergarage 6 ปีที่แล้ว +3

      ...how? It's useful, versatile and lightweight.
      Unlike syste.md

  • @Discordianism
    @Discordianism 6 ปีที่แล้ว

    Yumm boi u look fine 😘 did u get that care package I sent ya? 😊❤️❤️❤️

  • @nolifeorname5731
    @nolifeorname5731 6 ปีที่แล้ว +1

    gonna get hate for this one, but systemd timers work fine for me

  • @duffman6088
    @duffman6088 6 ปีที่แล้ว +1

    first

    • @elsholz2365
      @elsholz2365 6 ปีที่แล้ว

      You only realize how important "first" comments are, if you are missing them .-.