My hosting provider panel doesn't allow to add next cron job command:
"/home/username/.acme.sh"/acme.sh --cron --home "/home/username/.acme.sh" > /dev/null
due to 'Some characters are not allowed for cron job command' error.
After reading this post about it I'm trying to understand how to run it from a script (~/run-acme.sh
) and add it to a cron job but don't know how to do it (the example is using a PHP script).
Here's the content of the run-acme.sh
script but don't know what to write before the command (source
, .
or bash
) as this answer suggests:
Option 1:
#!/usr/bin/bash
bash "/home/username/.acme.sh"/acme.sh --cron --home "/home/username/.acme.sh" > /dev/null
Option 2:
#!/usr/bin/bash
source "/home/username/.acme.sh"/acme.sh --cron --home "/home/username/.acme.sh" > /dev/null
Option 3:
#!/usr/bin/bash
. "/home/username/.acme.sh"/acme.sh --cron --home "/home/username/.acme.sh" > /dev/null
Which of these options will work? Do they run with the same result?
Important note: don't have access to crontab/SSH
I believe you want option 1, because you want to run the acme.sh
script.
Option 2 and option 3 are essentially equivalent in bash, because source
is an alias to .
in bash. However, they are not equivalent in sh
, because .
exists in sh
but source
does not (this is because source
a non-POSIX bash extension).
When source
or .
are used, this is similar to using :load
in Haskell's GHCi or Scala's REPL, or load
in Lisp or Clojure. The source
or .
commands tell the shell to read, parse, and evaluate code written in a separate source file in the context of the current shell. Essentially, it allows functions and variables defined in a separate file to be made available in the context of the "calling" shell script.
What option 1 will do is run the acme.sh
. You want this option because you don't want the acme.sh
script to be run in your current shell (you might have some aliases or functions already defined in your current shell that could cause naming collisions). Running bash acme.sh
is similar to running python my_code.py
: the bash interpreter will execute the contents of acme.sh
.
For more info on source
and .
, see:
help source
and help .
at your bash promptsource
is non-POSIX)