You must have been using the Hermes Cron bot as it has a script named cf-dyndns.sh that should handle these tasks for you.
Here are the steps to follow:
1. **Navigate to hermes-bots**: Run
cd /hermes-bots (this will change your current directory, you can do this in any directory without worrying about conflicts with other bots)
2. **Update hereself**:
* ``
bash
echo "herescripts/df-dyndns.sh: Checking status"; \
df -h | grep dyndns > /dev/null; \
if [ $? -eq 0 ]; then
echo "[Success] DynDNS service is already running"
else
echo "[Error] DynDNS service is not installed or not enabled"
exit $?
fi
`
* **Update the Cron job:**
You should add a line like this after setting up your bot to run at the desired interval, which can be found on the [Hermes Website](https://hermes.sh/) documentation page. Here is what each column is for:
`
bash
*/[interval] 5 * * *
* * * * herescripts/df-dyndns.sh &
`
The */[interval]
specifies that this script should run every [interval]
seconds (for example, every minute), and the */[interval] ? * ? * ? * ? ? * ?
part inverts to match your desired scheduling of intervals.
* **Run the command, you just need to replace /root/.hermes/skills/cf-dyndns.sh** and provide a correct script path.**
You should change
*/[interval] 5 * * * /root/.hermes/skills/cf-dyndns.sh in your shell to run every second, **2 seconds**
Here is some code you can add to your Herescript script to achieve this.
``
bash
#!/path/to/a/b/f/your/script.sh
#!/bin/bash
## Set the interval between command checks.
CrontabInterval=0 # You can change this value if needed
Interval='*/[interval]' $CrontabInterval
case $1 in
dyndns)
cd /hermes-bots
python -i your/herescript.sh >> /dev/null 2>&1;
;;
*)
echo "Script not found: '$(basename your/herescript.sh)'" >&2
return 1
esac
`
You must replace your/herescript.sh
and the path to the script, in this example /hermes-bots
.
Then, you must have a file named your/script.sh
with an exact filename that follows the syntax.
Here's what it should look like if your script is a python executable:
`
bash
#!/bin/bash
import sys
import platform
from herescript import *
if __name__ == '__main__':
try:
# Create Herescript file if not already created
create_file(
'Hermes Bot Name',
'path/to/your/HERESKRIPT'
)
## Set the interval between command checks.
Interval='*/15 2 * * *' # You can change this value if needed
except sys.error as eError:
# Remove error messages like "permission denied"
exec_error_message(eError)
print('[Success] DynDNS service is up')
`
This is just basic code to help you. Your script should now have the time interval every 15 seconds in minutes and *run using: 2:00 AM, which means that after every two hours.
Please be aware of cron jobs because if they get executed too often, your Herescript could go into an infinite loop or fail silently.
Here's how to set up it so you run only once a day:
### Install python and put your script on your system
* If the above commands are not found: install python from official website
http://python.org
* Copy your herescript file onto your path:
python -m pip3 herescripts/install herescriptscript.py
This script needs permissions to write files. That's why you should save it with .bash, so if there are two bash scripts I have in my herescripts/ dir we won't run the python install first.
* Run python2 -c "from your/bot_script import sys" || exit 1` with cron job to use Python and get an error message when you try to install it.