<SOLVED> How to use Cronie?

I installed Cronie, but having a problem using it. I’d like to use it to reboot the computer every day at a certain hour. Anyway, running crontab -e in Terminal, I get this:

Welcome to the Haiku shell.

~> crontab -e
no crontab for user - using an empty one
/bin/sh: line 1: /usr/bin/vi: No such file or directory
crontab: “/usr/bin/vi” exited with status 127
~>

I think the error is related to cronie trying to use Linux’s Vi text editor, which doesn’t exist in Haiku. I can manually create and edit a crontab file, but I don’t know where to create it. Can anyone assist? Thanks

Vim is an improved version of Vi. Getting Cronie to recognize it might be difficult. How familiar are you with Bash scripting and Cron tables?

vi is the “fallback” editor for many (ported) terminal programms.

You can usually set the EDITOR env variable to another (blocking) text editor for ported applications so they use this instead

It is. pkgman install vim.

vi isn’t vim

Vim is largely vi compatible, mostly extending the features. Given that cronie most likely only wants to open a temporary crontab file with it it don’t expect any compatibility issues. But that’s only guessing, the OP will have to try it out. And if it works maybe vim should be included in the dependencies for cronie.

Thanks for letting me know :wink:
Let’s not get into nitpicking wars on Easter Sunday, shall we? As I wrote above, cronie most likely wants to call vi to simply open the crontab file. I don`t expect any vi vs. vim compatibility issues doing that.

I already wrote what to do above, most likely it does not care what editor it wants.

export EDITOR=nano and then call the command.

(and as someone who really liked nvi on FreeBSD but didn’t manage to use vim or nvim i’m certainly of the opinion it isn’t the same programm : )

The missing editor doesn´t seem to be the only problem with cronie. I have vim installed and get these errors:

~> crontab -e
/packages/cronie-1.5.2-2/.self/var/spool/cron: No such file or directory
/packages/cronie-1.5.2-2/.self/var/spool/cron: mkdir: No such file or directory

Looks like cronie wants to create the crontab file within the package itself, which obviously doesn´t work. This is not surprising because looking at the haikuports recipe there is no patch applied that does anything to point cronie at the right spool directories on Haiku (or at least I didn´t find any).

I think we really should have an integrated task scheduler on Haiku that can be configured via GUI to avoid having users messing around with cron-like programs. Sure, a having a task scheduler is probably not a high priority on a desktop OS but very useful sometimes nonetheless.

@kp3ft : There was a discussion about something similar on the forum a while ago, where a script was posted that runs in a loop and mimics the behaviour of a simple task scheduler. Maybe this could be a workaround for you for the time being.

Yeah, that was probably one of my previous posts. I need the Haiku computer to reboot at a particular time every very early morning. Some folks posted some scripts to try, but I couldn’t get them to work.

1 Like

It works! I did export EDITOR=nano and then crontab -e . Added a reboot statement in the crontab file and saved it. Computer rebooted right on schedule.

What worked for me to get Cronie working:

  1. Install Cronie from the package manager.
    2.Run in Terminal:
    mkdir -p /boot/system/var/spool/cron
    ln -sv /bin/crond ~/config/settings/boot/launch/crond
  2. Reboot (might not be necessary, but I rebooted anyway.)
  3. Run in Terminal:
    export EDITOR=nano
    crontab -e
3 Likes

.self links back to /system

It wants to create /system/var/spool/cron after figuring out it doesn’t exists, but it assumes /system/var/spool already exists.

It’s likely not that hard a fix to the port to make it use mkdir with the option to create intermediate directories, and use another editor.

1 Like

It probably should exist. It’s one of the BeAPI find_directory constants(B_SYSTEM_SPOOL_DIRECTORY). Then there would be no need to modify the cronie code.

I would join this scheduler stuff

Gr8 that crontab solved below …

Can someone add at command as well - I miss it : )
It should be standard POSIX command if I know well.

Ok I see, some OS uses an additional daemon ‘atd’ - so I see it is a bigger task to port / implement it to Haiku.