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?

  • 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!


    OMV AMD64 5.x on ASRock Rack C2550D4I C0 Stepping - 16GB ECC - Silverstone DS380 + Silverstone DS380 DAS Box.

  • 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.

  • ...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.

  • 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?).

  • 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.

  • 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

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!