DisposableHero Posted February 9, 2022 Report Share Posted February 9, 2022 (edited) Hi, This is technically not a guide, but an overall explanation of v7 systems related to automation and why CRON is needed etc. What is CRON ? Basically CRON is the name of "Scheduled Tasks" in Linux systems. Imagine it like a person executing tasks in behalf of you, a helper or an automation. Why it is needed and important ? Well, if you want to execute every single script needed for automation then you do not need it, but most of us do not have that much free time, specially we can not be online 24/7 to click some links every single minute or at best every hour. So CRON is important because it does exactly this. It runs some scripts, at minimum every single minute to see if there is something needed to be done. If not it waits and then checks again, again and again without any problems. What will happen if I do not have a working CRON ? To be honest, in the first days you will notice nothing about it. There will be practically no visual clues, no problems, everything will look ok and you will think that your v7 VA is running fine. The truth is, no it is not running fine, it is just piling up some possible problems and they will hit you hard soon. Here is a simple list I can think of related with CRON in v7; Every hour it checks your bids and deletes expired ones Every hour it checks your SimBrief packs and deletes expired + non used ones Every hour it checks your live flights and deletes them if they are stuck/frozen etc Every hour it checks your pilot reports (pireps, flight reports) and delete cancelled/rejected ones Every night it re-calculates the stats of your pilots, corrects them if there is an inconsistency Every night it re-calculates the financial data of your airline(s) and pilots Every night it checks and executes your daily expenses Every night it checks your schedule and activates/deactivates flights for that day/date Every night it checks your pilots to determine if they are still active or not Every month it checks and executes your monthly expenses These were just for the core, also addons/modules may need CRON (for this I can only speak for my addons of course) but you can expect it to be extended easily with new addons/updates; Every hour it checks your fleet, fixes problems about aircraft state, grounds them if they somehow get stuck "in air" or "in use" Every hour it checks your maintenance records, releases aircraft back to service (or keeps them grounded) Every month it executes tasks for monthly flight assignments Also you can extend core CRON usage, for example it can organize sending mails in the background to speed up things and save you from mail server slowdowns etc. And of course it is possible to develop more functions to be handled automatically, image yourself doing database cleanup every week or month, or always executing same things in a timely manner, to automate all these task you need a working cron. Like in my setup, it does more than the list above, I am happy and focused on other things and enjoying flights etc. What is the minimum interval for CRON timing needed ? If it is not hurting your server and if it is allowed (some hosting companies limit this), set it to run every 1 minute or 5 minutes. If not possible use the minimum possible period, maybe 15 minutes or 30 minutes. This will not hurt v7 much, why 'because as you can see above it executes the main tasks mostly with one hour intervals. So what happens if you set your cron to run every single minute. Nothing harmful, it just checks the time and tasks then stops, when it is the correct time then it executes the tasks and then stops again. Same thing will happen if you set it to run every 30 minutes too. Only the checks will be less frequent that's all. BUT, if you are planning to use cron for e-mail scheduling, then this timing becomes more important. Imagine a scenario, you enabled cron for emails (check docs for details) and set it to run every 30 minutes; 10:00 > Cron runs, executes hourly tasks 10:03 > A new pilot registers, mail is placed in the queue and waiting 10:12 > One of your pilots send a pirep, mail is placed in the queue and waiting 10:30 > Cron runs, no hourly tasks available, so it sends the mails only 10:31 > You get mails from your system, go check and approve the pilot and reject the pirep, mails are placed in the queue and waiting 10:48 > Another pilot sends a pirep, mail is placed in the queue and waiting 11:00 > Cron runs, executes hourly tasks and sends the mails 11:02 > You get another pirep notification and so on How can I set the CRON ? This is normally done via the control panel you are using, it may be CPanel or Plesk or something custom. If you can not see anything named like CRON, CRONTAB, Scheduled Task etc in your control panel, please consult your hosting providers documents and/or support. Also you can find an example code at admin > maintenance page, but it is an EXAMPLE, it may or may not work. You can use that example as a starting point or maybe use it while speaking with your hosting support staff. How can I understand my CRON is working or not ? Simple, check your storage/logs folder. If it is working as expected you will have a log file named something like cron-2022-02-08.log , if that file is not there this is an indication of either it is not configured right or it is not working. To get more details now check your laravel logs, if you see something like `production.ERROR: The Process class relies on proc_open, which is not available on your PHP installation.` in the log then this means that the CRON is trying to work but it can not. So the setup is correct, but you are now facing a much bigger problem. Your hosting company is limiting things, you can speak with them for more details, some do help and let you proceed, some will not. *** Update ; With the improvement to development build, now it will be possible to have CRON system working with limiting hosting companies too. Please check the docs about latest changes. *** My hosting provider does not offer CRON, what can I do ? You can use the built in web cron feature of v7, there are lots of free/paid services offering you to run web based crons. If you are getting the error explained above, this solution will not work either, so do not expect miracles. I have hosting related CRON problems, what can I do to solve this ? You can write your own web cron compatible code to bypass your hosting companies limitations, but for this you need to have some php + laravel + v7 knowledge. This is nothing impossible, but it is not easy either. Honestly you are on your own there, but what you need is basically to study the core cron tasks, duplicate and enhance them for your own usage. Or you can find another host, switch to another package/service they provide, switch to VPS or rent your own server, whichever you prefer. Finally; Please remember, v7 will install and work without CRON but you will loose some of its important and really needed abilities and features. Safe flights. Edited February 11, 2022 by DisposableHero Dev Updates 2 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.