I’m working on a few scripts to create txt files, rsync a few files to a remote server, backup the server database, and send the backup to offsite storage. The SQL file is about 150MB, so not too small.
These scripts need to follow each other in a certain order, so the txt files are created before the backup, etc. All are php or bash scripts.
I found that I can use a semicolon (;) in the scheduled task to separate scripts and run them one after another, instead of scheduling them half hour or a few minutes apart.
Is it recommended to create individual tasks with one script per task, or can I combine 5-7 scripts together in the same scheduled task?
Will that overload the server? I don’t want to generate errors, or have the server get out of whack.
Thanks!
‘;’ should definitely be preferred. Or – even better- you can put your tasks in one executable .sh file (separate by ‘;’ or simple put each task on separate line) and schedule running this file as a single item. Except if your server is somehow configured to limit long running cron tasks, I cannot see any problem with that.
Running several individual tasks with a delay may definitely cause problems if 2nd task will start before 1st finishes. I would recommend to avoid that.