Why is crontab missing on Home Assistant OS host?

I am trying to add a cron job to my HAOS host. (My aim is to send some stats of the host to Home Assistant via curl to a restful sensor.)

However, after successfully logging into the host as root user using SSH, I receive the error that crontab is not found:

Is it expected that cron should not be available on the host?

I’ve seen many instances on the forum of people adding cron jobs, but nobody is complaining that cron is not installed. Is it expected that it needs to be installed manually, or am I missing something?

Thanks

Because the base OS isn’t intended for that kind of thing - it’s deliberately a minimal OS.

That and if that’s one of the SSH add-ons then, well, they’re not the host. You can probably install cron using the community SSH add-on, but why not just have those stats sent by Home Assistant itself?

@Tinkerer I am definitely SSH’ing into the host (not the supervisor or homeassistant containers, or any of the addon containers). I am using the developer SSH port 22222, and connecting from PuTTY on a different machine (not the SSH add on terminal).

The reason I need to have the stats sent by the host, and not “by home assistant itself”, is because I want to grab some information on a network NFS drive that was configured as “storage” for backups through the Home Assistant frontend. Specifically, I want to know that the NFS drive is successfully mounted and writable, as well as getting its disk usage.

Unfortunately, when mounting an NFS drive as a storage for backups, it is mounted to the host, but is NOT bind-mounted into the homeassistant docker container (although it is mounted into the supervisor container). Therefore, “home assistant itself” cannot see a mounted NFS drive through the command line, and is not able to grab any of the stats I am looking for. This is the reason for needing the host to provide the stats for me.

Then you’re in a very limited, locked down, environment - deliberately. It lacks far more than just cron.

You’re probably going to have to use an automation to SSH to the host and run the command you want.

Yes, I was hoping to avoid that, because of the security implications of giving the homeassistant docker container SSH access to the host. As well as the fact that I would need to give the homeassistant container the private SSH key (and would also need a SSH key without a passphrase, in order to execute it via a shell_command service).

I was hoping to do it using this method with a named pipe, but this method appears to use cronjob on the host. I’m not sure how it was achieved in that case.

Also, if I was to install cron using the community SSH add-on as suggested, then this would install it only for the corresponding docker container. Since the mounted storage drives are not bind-mounted into the add-on docker containers either, then this still wouldnt solve my problem.

Since you didn’t clarify why you needed cron originally the suggestion I made at that time was made based on the information you’d shared.

You’ll note that your clarification came after that suggestion.

Yep sure. I was just being explicit for the benefit of anyone else coming along reading this who might be trying to achieve a similar thing.

Im still surprised to find so many references on the forum to people using cron jobs with Home Assistant. Yet no mention of anyone manually installing cron on their system.

Also, if cron was installed manually in the container (via the SSH addon terminal for example), then presumably it would be removed every time the docker container was removed. For example during a system update. Again im very surprised not to find more people running into this when they are using cron.

What do you make of this? What am i missing?

The people who run cron don’t run HA OS. We all run something else that lets us do whatever we want. e.g. HA Core on Ubuntu, or HA Container, or HA Supervised (not recommended).

Or we use automations to run commands. It’s the same stuff basically.

I see. Thanks for clarifying.