Scheduled jobs vs /etc/crontab

  • Hello,


    I've created a scheduled a daily rsync job to backup/mirror one drive onto the second.

    But there seem to be two issues with it:


    1. It's not working. It doesn't seem to be carried out consistently (but I will need to monitor this further)

    2. I cannot see this job in /etc/crontab.


    Now, according to this thread, OMV does not use crontab but instead "creates entries in the appropriate /etc/cron folder".

    I don't even have such a folder. All that is listed under C in the /etc is this:

    ca-certificates, ca-certificates.conf, ca-certificates.conf.dpkg-old, calendar, chrony, collectd, console-setup, cron-apt, cron.d, cron.daily, cron.hourly, cron.monthly, cron.weekly, crontab (and it's not in e.g. cron.daily either).


    So, can I just fill crontab "as usual" instead, just to get it working (haven't tried so I won't mess up the system)?

    Where should one be able to confirm the scheduled job from the GUI?

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

  • Look in the file /etc/cron.d/openmediavault-userdefined


    Look at the files in /var/lib/openmediavault/cron.d

    --
    Google is your friend and Bob's your uncle!


    A backup strategy is worthless unless you have a verified to work by testing restore strategy.


    OMV AMD64 7.x on headless Chenbro NR12000 1U Intel Xeon CPU E3-1230 V2 @ 3.30GHz 32GB ECC RAM.


  • Look in the file /etc/cron.d/openmediavault-userdefined


    Look at the files in /var/lib/openmediavault/cron.d

    Both are empty.

    But for some reason, the scheduled rsync job seems to work now.


    For future planning: Where would I write another scheduled job into?

    I'm planning to store a video stream from a CCTV for 24hrs, so was planning to rip the video stream and restart the service every 24hrs to overwrite the previous one.

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

  • ...correction:


    I was logged on as root, so changed to the user level.


    /etc/cron.d/openmediavault-userdefined does have a cron job listed with a coded reference which refers to an entry in /var/lib/openmediavault/cron.d where the shell command is spelled out.

    Both contain the warning that each will be overwritten by the system, so no editing.


    Where would I edit cron jobs (apart from the GUI)?


    One thing I like about editing the crontab directly is that one can set a specific time, a date and there are just some more options than the GUI provides.

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

  • I'm planning to store a video stream from a CCTV for 24hrs, so was planning to rip the video stream and restart the service every 24hrs to overwrite the previous one.

    For this, maybe you can consider running a "motioneye" docker:

    ccrisan/motioneye: A web frontend for the motion daemon. (github.com)

    Helping someone once over a jellyfin issue, I created a "proxy-conf" to use it (motioneye) over the web through SWAG.


    If you need/want to go that way, say so and I'll post it here, ;)



    Where would I edit cron jobs (apart from the GUI)?

    One thing I like about editing the crontab directly is that one can set a specific time, a date and there are just some more options than the GUI provides.

    If you want to edit the crontab tasks of a user, just run crontab -l to view (List) the assigned cronjobs and crontab -e to edit (Edit) the file.

    You have to be logged with the specific user that you want to change the file.

  • Hm, thanks for the manz ideas.

    I'm currently testing Mplayer for this, see how this goes then go further maybe.


    Regarding cron:


    crontab -l returned:

    no crontab for USER1


    crontab -e says:

    no crontab for USER - using an empty one

    touch: cannot touch '/home/USER1/.selected_editor': Permission denied

    Unable to create directory /home/USER1/.local/share/nano/: No such file or directory

    It is required for saving/loading search history or cursor positions.

    Press Enter to continue


    If I press enter, it opens an editable crontab file but under the path:

    /tmp/crontab.eWTaUC/crontab

    ...so nothing permanent apparently.


    So I checked the permissions. Maybe the directory was created and owned by root and chowned /home/USER1 to USER1:USER1.


    Now the output of crontab -e is:

    no crontab for USER1 - using an empty one

    ...with the path /tmp/crontab.dDQ4nl/crontab


    nano crontab just opens a blank page (which I am tempted to fill and save under /etc/crontab ...should I?).

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

  • Now the output of crontab -e is:

    no crontab for USER1 - using an empty one


    ...with the path /tmp/crontab.dDQ4nl/crontab

    nano crontab just opens a blank page (which I am tempted to fill and save under /etc/crontab ...should I?)

    Yes, you're editing a "tmp override" file that will be "automagically" added to the crontab jobs. After editing, just Ctrl+O+Enter and then Ctrl+X


    It usually is something like this:



    The two commands explained in there :

    Code
    # m(inute) h(our)  dom(day of month) mon(th) dow(day of week)   command
    # *= Every minute/hour/dom/mon/dow
    33         */3     *                 *       *            ~/duckdns/duck.sh >/dev/null 2>&1 # run every 3h (*/3) at minute 33
    37        13,19,23 *                 *       *    docker restart motioneye >/dev/null 2>&1 # run at 13h37m; 19h37m and 23h37m
  • So you are suggesting to use the temporary crontab file instead of just using a blank one and save it under /etc/crontab?


    I'm familiar with crontab files and I love their flexibility and options. It's more than the GUI provides :)

    Kind of became a command line guy now...


    It only leaves the question of where the existing (and functioning) cron job from the GUI went.

    If I make another crontab file, I may end up running a job twice (or not at all if there's a clash). So could go and delete the one from the GUI.

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

  • I'm not suggesting nothing, this is the way to edit the crontab.


    Since you asked how to edit the crontab from other way than the GUI (assumed you meant OMV scheduled jobs), I replied.


    You can try to sudo crontab -l and see the jobs for root

    • Offizieller Beitrag

    It only leaves the question of where the existing (and functioning) cron job from the GUI went.

    See #2 and #3 depending on what you set up (rsync or scheduled job)

  • Right, it's been a while and yes I managed to place a cron job on the user level using the temporary file that came up.


    I know there is another scheduled job on the GUI for this user.

    But crontab -l when logged on as this user will only show the newly created one.


    So I logged on as root and found no cronjobs listed for root at all.


    Am I still digging in the wrong direction?


    Just to add why I prefer the terminal: I cannot logon via the GUI with https.

    If I force it, I get locked out, but neither Firefox nor other browsers give me a https connection and jump back to http, port 80.

    Different topic, but that just explains why I prefer the ssh logon via the terminal.

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

    • Offizieller Beitrag

    But crontab -l when logged on as this user will only show the newly created one.


    So I logged on as root and found no cronjobs listed for root at all.

    OMV does not use crontab

    Am I still digging in the wrong direction?

    For what?


    If you want to create a cron job, just add it to /etc/cron.d as mentioned here


    RE: Where does OMV store an editable crontab?

  • Ok, so here is what I did and still can't get a customised cron job going via the terminal (which I prefer since I can't get an httpS login via any browser):


    created a new cron job by adding a new crontab to /etc/cron.d - did not execute, works if executed manually;

    wrapped the cron command in the above cron job in a shell script - works if executed manually;

    used 'crontab -e' when logged in as a user - does not work, command works when executed manually.


    Indeed the cron job I defined via the GUI once is in /var/lib/openmediavault/cron.d/userdefined-..... Not the one to edit.


    I'm clueless. I could start fixing the GUI / httpS issue but when you are used to the command line anyway... GUI feels like Windows to me ^^

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

  • What exactly did you add to /etc/cron.d?

    And what do you want to achieve by this?

    I added a cron job / crontab file, the one I actually wanted to work using 'crontab -e' as a user (not root).

    /etc/cron.d/openmediavault-test however I had to create/modify as root, so not ideal.


    This is all because I can't get a cron job to work using 'crontab -e'. OMV just won't do it and I like to use the command line as I'm having issues getting httpS access via the GUI. The command line always works, regardless of browser issues (which it may be but I also blame OMV for this...).


    So what I discovered is:

    OMV does seem to execute cron jobs when I log in as root, add a crontab file to /etc/cron.d/openmediavault but it won't do it if you do it the "OEM way" using 'crontab -e' as a user.

    It somehow gets lost or not entered into the permanent userdefined crontab as it should be.


    A bug?

    Some content might be slightly modified to mask personal settings- just to keep the sharks away, you never know :)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!