arkmanager / ark-server-tools

Set of server tools used to manage ARK: Survival Evolved servers on Linux
MIT License
680 stars 144 forks source link

Install-cronjob is vague #1155

Open Uskaanax opened 3 years ago

Uskaanax commented 3 years ago

Could the information on --install-cronjob be expanded to provide examples, please?

klightspeed commented 3 years ago

install-cronjob

Installs a cron job that executes the specified command.

This accepts any of the options the specified command accepts, as well as the following options. In order to specify an argument to the command (e.g. to the broadcast command), use the --arg=<arg> option.

Please read your man 5 crontab manpage to determine what minute and hour values are valid, as some implementations may not accept e.g. the */n minute / hour specification.

--daily

The command should be executed daily

--hourly

The command should be executed hourly

--hour=<hour>

Specifies one or more hours when the command should execute. This is the hour field of the cron job. If you want to have the command execute every n hours, then use --hour='*/n'

Default: * (i.e. all hours)

--minute=<minute>

Specifies one or more minutes of the hour when the command should execute. This is the minute field of the cron job. If you want to have the command execute every n minutes, then use --minute='*/n'

Default: 0 (i.e. the first minute of the hour)

--enable-output

Enables the output from the command - the cron daemon usually emails this to the user specified in the cron configuration

--arg=<arg>

Specifies an argument to pass to the command

For example, to install a cron job that will insert the following into your crontab:

0 * * * * /path/to/arkmanager --cronjob broadcast @main --args Hi\ Everybody -- >/dev/null 2>&1

you would use:

/path/to/arkmanager install-cronjob --hourly broadcast @main --args "Hi Everybody"
fossum commented 1 year ago

I feel this is vague too. The example is good, but args are still lacking. First it's arg then args and can you show a real world example with more than one flag? Too be honest, I can't even get it to manually work with one flag... I'm using the following and notice the lack of warning in output.

~ /usr/local/bin/arkmanager install-cronjob --daily restart @fjordur --arg=warn  
➜  ~ crontab -l
0 * * * * /usr/local/bin/arkmanager --cronjob backup @all -- >/home/ericfoss/ark-cron-backup.log 2>&1
0 * * * * /usr/local/bin/arkmanager --cronjob restart  @fjordur  --args  warn -- >/dev/null 2>&1
➜  ~ /usr/local/bin/arkmanager --cronjob restart  @fjordur  --args  warn                   
Running command 'restart' for instance 'fjordur'
Stopping server; reason: restart
The server has been stopped

Expected behavior

➜  ~ /usr/local/bin/arkmanager restart @fjordur --warn    
Running command 'restart' for instance 'fjordur'
This ARK server will shutdown for a restart in 60 minutes
klightspeed commented 1 year ago

--arg=<arg> --arg=<arg2> ... specifies one or more arguments that will be supplied to the command using the --args <arg> <arg2> ... -- option/arg/terminator sequence, which is required for non-option arguments to not be interpreted as a subsequent command.

--options (such as --warn) do not need to be added using --arg=, as they are not in danger of being interpreted as a subsequent command.

If you still want to pass --warn using --arg=, then try using --arg=--warn

Edit: For install-cronjob, the following two sequences are identical:

--arg=<arg1> --arg=<arg2>

vs

--args <arg1> <arg2>

and the -- terminator to --args is optional if it's the last command passed to arkmanager