jobbyphp / jobby

Manage all your cron jobs without modifying crontab. Handles locking, logging, error emails, and more.
https://packagist.org/packages/hellogerard/jobby
MIT License
1.05k stars 154 forks source link

run command using zsh or bash shell? #123

Closed llbbl closed 4 years ago

llbbl commented 4 years ago

Seems the jobs are being run with the 'sh' shell. I am using my current user in the crontab side, whose default shell is zsh.

I tried adding a switch to zsh before the command

 zsh && <command>

The PATH for zsh is much different than the sh shell. I think options are

Unless I am missing something?

llbbl commented 4 years ago

Okay I figured it out. You have to create a .zshrc file with the stuff you need in it. Then set a environment variable ZDOTDIR. Haven't tried setting environment variable via jobby feature yet.

'command' => 'ZDOTDIR='.__DIR__.'/.zshrc zsh -c "<command>"',

It also works if you create a simple wrapper bash file and have jobby call that.

Example:

#!/bin/zsh
source .zshrc
<command>
llbbl commented 4 years ago

Oh yea in case it wasn't obvious from me figuring it out above, you run commands through zsh shell using -c flag.

zsh -c "<command>"