title: How to run a cron script with gitlab-rails
body: <p>I have gitlab-rails with</p>
  <ul>
  <li>GitLab 15.0.4</li>
  <li>Rails version 6.1.4.7</li>
  <li>Ruby version ruby 2.7.5</li>
  </ul>
  <p>I want to run a gitlab-rails script from Cron. The <code>gitlab-rails runner</code> seems to be broken as it doesn't recognize the file argument and tries to run it as a script instead, which fails. So even if the shebang line suggested in <code>gitlab-rails runner -h</code> worked (which it doesn't on my system because args are not separated), gitlab-rails runner complains that the file path is not a valid script.</p>
  <p>I could include the ruby script in a shell script, pipe it to gitlab-rails, but sacrifices .rb file syntax highlighting and intelisense in editors.</p>
  <p>I could pipe the <code>.rb</code> script from within a shell script into gitlab-rails. That would solve the previous, but now I have two scripts and shell is not reliable when it comes to referencing related scripts unless I give it the library path explicitly. That seems convoluted.</p>
  <p>Someone <a href="https://github.com/rails/rails/issues/665" rel="nofollow noreferrer">folks have suggested workarounds</a>. It involves running ruby as usual and then re-executing the script with rails (gitlab-rails in my case). This still fails because of the broken gitlab-rails runner which treats the file argument as a rails command...</p>