jamesrwhite / minicron

🕰️ Monitor your cron jobs
GNU General Public License v3.0
2.34k stars 154 forks source link

I receive an error message when I try to start minicron. #169

Closed schueszy closed 8 years ago

schueszy commented 8 years ago

./minicron run ls error: undefined method `[]' for nil:NilClass. Use --trace to view backtrace

jamesrwhite commented 8 years ago

Can you let me know what version of minicron you are using (you can get this from minicron -v) and what OS?

schueszy commented 8 years ago

root@xxx:/etc# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty root@xxx:/etc# ./minicron -v minicron 0.8.3

jamesrwhite commented 8 years ago

Yeah I can reproduce but only on linux not osx strangely, will have a look.

jamesrwhite commented 8 years ago

Ah, do you have an existing config file at /etc/minicron.toml? I made a breaking format change to that in a recent release, yours likely needs to be updated. I could reproduce the same issue on my own server that had an older version of the file. See minicron.toml for the most up to date example.

schueszy commented 8 years ago

Yes i have an existing file. I downloaded yesterday from github. I use mySQL instead of sqllite.

# Example config file

# Global options
verbose = true
debug = true # Useful for debugging

# Client options
[client]
scheme = "http" # [http, https]
host = "0.0.0.0"
port = 9292
path = "/"
connect_timeout = 5
inactivity_timeout = 5
  [client.cli]
  mode = "line" # [line, char] - line by line output or char by char
  dry_run = false # When true the command is run but not sent to the server

# Server options
[server]
host = "0.0.0.0"
port = 9292
path = "/"
pid_file = "/tmp/minicron.pid"
cron_file = "/etc/crontab"
  [server.session]
  name = "minicron.session"
  domain = "127.0.0.1"
  path = "/"
  ttl = 86400
  secret = "change_me"
  [server.database]
  type = "mysql" # [mysql, postgresql, sqlite]
  # The options below are for mysql and postgresql only
   host = "127.0.0.1"
   database = "minicron"
   username = "root"
   password = ""
  [server.ssh]
  connect_timeout = 10

# Alerting options
[alerts]
  [alerts.email]
  enabled = false
  # from = "from@example.com" # "Your Name <from@example.com>" syntax is also supported
  # to = "to@example.com"
    [alerts.email.smtp]
    address = "localhost" # "smtp.gmail.com" for gmail
    port = 25 # 587 for gmail
    # domain = "your.domain.name"
    # user_name = "username@email.com"
    # password = "password"
    # authentication = "plain"
    enable_starttls_auto = true

  [alerts.sms]
  enabled = false
  # from = "+442222222222"
  # to = "+443333333333"
    [alerts.sms.twilio]
    # account_sid = "YOUR_TWILIO_ACCOUNT_SID"
    # auth_token = "YOUR_TWILIO_AUTH_TOKEN"

  [alerts.pagerduty]
  enabled = false
  # service_key = "YOUR_PAGERDUTY_SERVICE_KEY"

  [alerts.aws_sns]
  enabled = false
  # secret_access_key = "YOUR_SECRET_ACCESS_KEY"
  # access_key_id = "YOUR_ACCESS_KEY_ID"
  # region = "AWS_REGION"
  # topic_arn = "YOUR_SNS_TOPIC_ARN"
jamesrwhite commented 8 years ago

Apologies, there was an error in the example config that you based yours on. I fixed yours and it should be:

# Example config file

# Global options
verbose = true
debug = true # Useful for debugging

# Client options
[client]
  [client.server]
  scheme = "http" # [http, https]
  host = "0.0.0.0"
  port = 9292
  path = "/"
  connect_timeout = 5
  inactivity_timeout = 5
  # CLI options
  [client.cli]
  mode = "line" # [line, char]
  dry_run = false

# Server options
[server]
host = "0.0.0.0"
port = 9292
path = "/"
pid_file = "/tmp/minicron.pid"
cron_file = "/etc/crontab"
  [server.session]
  name = "minicron.session"
  domain = "0.0.0.0"
  path = "/"
  ttl = 86400
  secret = "change_me"
  [server.database]
  type = "mysql" # [mysql, postgresql, sqlite]
  # The options below are for mysql and postgresql only
  host = "127.0.0.1"
  database = "minicron"
  username = "root"
  password = ""
  [server.ssh]
  connect_timeout = 10

# Alerting options
[alerts]
  [alerts.email]
  enabled = false
  # from = "from@example.com" # "Your Name <from@example.com>" syntax is also supported
  # to = "to@example.com"
    [alerts.email.smtp]
    address = "localhost" # "smtp.gmail.com" for gmail
    port = 25 # 587 for gmail
    # domain = "your.domain.name"
    # user_name = "username@email.com"
    # password = "password"
    # authentication = "plain"
    enable_starttls_auto = true

  [alerts.sms]
  enabled = false
  # from = "+442222222222"
  # to = "+443333333333"
    [alerts.sms.twilio]
    # account_sid = "YOUR_TWILIO_ACCOUNT_SID"
    # auth_token = "YOUR_TWILIO_AUTH_TOKEN"

  [alerts.pagerduty]
  enabled = false
  # service_key = "YOUR_PAGERDUTY_SERVICE_KEY"

  [alerts.aws_sns]
  enabled = false
  # secret_access_key = "YOUR_SECRET_ACCESS_KEY"
  # access_key_id = "YOUR_ACCESS_KEY_ID"
  # region = "AWS_REGION"
  # topic_arn = "YOUR_SNS_TOPIC_ARN"
schueszy commented 8 years ago

YEAHHH!!!! Thank you Mr White it works!!! ;-) root@xxx:/etc# ./minicron run ls [minicron] started running ls at 2015-11-21 14:39:45 UTC

But now i tried to create an job on the webinterface:

The server settings are correct. You can see here: image

But after I've created a job , nothing happens image

jamesrwhite commented 8 years ago

So I think the likely issue here is that minicron is not in your $PATH, when entries are put in the crontab it is assumed that this is the case. I'm still trying to work out the best way to solve this as with the new packaged versions of minicron its become a bit more complicated as minicron is no longer installed as a gem.

My short term recommendation would be to add the location of the unzipped minicron directory to your $PATH, you will need to do this in your /etc/crontab.

As an example mine currently looks like this:

SHELL=/bin/sh
PATH=/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

* * * * * james /bin/bash -l -c 'minicron run '\''echo 1'\'

..but you will need to add the minicron directory path to your $PATH, e.g

PATH=/path/to/minicron/directory:/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
schueszy commented 8 years ago

Thank you very much now it works!