Change the “Command” input field from a normal text field, to a large text area.
Problem/Justification
It is currently difficult to enter or edit long cron commands in the panel for a cron job in the Web UI. The input field for “Command” is a normal single line box. Only 64 characters fit into the visible space of the Command field, and to view all characters after that, the user must scroll inside the box. It is therefore easy to lose a sense of position inside the box and not see the whole command.
A large text area would allow the user to edit the text much more easily and avoid making mistakes in their input.
This change would only be visual and in the UI. The field could still include validation to force the input to be a single-line.
Large text fields are already used elsewhere in the Scale Web UI. Here is an example of a large text field in the Data Protection > Cloud Sync Tasks.
Impact
It will become easier to add, manage and debug a user’s own cron jobs. Almost all cron jobs are usually long strings, even if they only point to a bash script. That bash script will most likely be in a filesystem location with a long path.
User Story
I use cron jobs for a number of backup tasks. All of the functionality is contained within a bash .sh script file. The path to the script is often long because it points to a location in my personal data area. However, I will also call the script not just directly but using systemd-cat
to log its output to the systemd journal and/or runitor
or another binary or script that will communicate with Healthchecks.io, to report progress. I also need to source an env file and specify the full path to the env file.
Right now I cannot practically edit the command inside the Web UI. It is too difficult to scroll the cursor to the left and right… I know I am bound to make a mistake so I don’t attempt this. Instead I edit the text in a text editor first and then paste it in the field. This process is obviously repeated many times if I am still troubleshooting the cron. This is an unnecessary step if the box in the UI was just large enough in the first place.
Devil’s Advocate
“If the cron command is long, it should be in a script”
In many cases, this would introduce 2 scripts. One script that contains the actual operations, and another script that contains the wrapping calls like systemd-cat, runitor and any script arguments that are specific to that cron. In the interest of low complexity, the cron command should be allowed to be as long as it needs to be. But all of the command should be accessible within that TrueNAS Web UI panel.