Cron keeps crashing

Please Note: The TotalFreedom Forum has now been put into a read-only mode. Total Freedom has now closed down and will not be returning in any way, shape or form. It has been a pleasure to lead this community and I wish you all the best for your futures.
  • So this is something I've been trying to figure out for the last two weeks now.

    So my schedules in Pterodactyl don't run. They get stuck on Processing. This is what the task looks like

    Nothing fancy, just takes a backup every night as 12 am. (The last ran was when I ran it manually)

    So it does run but gets stuck on Processing. So the clock is right and it knows when to run, but it gets stuck.

    So one website said to run

    Code
    rm -f /var/run/crond.pid  

    This actually works. If I type cron for the first time after doing that command, it will not output anything. However, when I run it again, I get an error like this

    Code
    cron: can't lock /var/run/crond.pid, otherpid may be 3078: Resource temporarily unavailable  

    So I delete the file and run cron again and it works. I also found out that schedules work if I don't run the cron command at all.

    All of this gets reset on a reboot (i.e. cron is crashed by default and I manually have to delete this file). Does anyone know how to stop this from happening? All the answers I found were very vague. One said stuff about changing the Python path, but nothing is related to cron and Python. I have Python 3.8.5 installed, but I don't think it's interfering or doing anything. I have the same problem on my VPN server and my Raspberry Pi. neither of which run Pterodactyl or any cron tasks at all. All are on Ubuntu 20.04 by the way. Any help or advice or a way to just automate deleting the file? Thanks

  • Go to Best Answer
  • Don't run cron manually. It's a Linux service that automatically starts on boot. That's why /var/run/crond.pid exists after you reboot and why jobs work if you don't run the command at all. The correct way to restart cron after a hang is sudo service cron restart.

    Also, /var/run/crond.pid existing is a good thing if cron is running, even if it is hanging. The website you found telling you to delete that file was talking about the situation where cron is not running at all.

  • @StevenNL2000#6790 I don't think cron was running at all then... It knew tasks were supposed to run but never did so I guess cron could have not been running in the first place.

    I downgraded to an earlier version of Pterodactyl and things have been working consistently better now. Gonna leave it that way for now.

  • @Telesphoreo#6795 If it was not running it might be worth checking the logs in /var/log on the server running the cron. I can't remember if cron has a dedicated log but I find /var/log/messages tends to be useful if weird stuff is going on that I can't find logs for elsewhere on the server.

    Wild1145

    Network Owner at TotalFreedom

    Managing Director at ATLAS Media Group Ltd.

    Founder & Owner at MastodonApp.UK

  • So this had nothing to do with cron. It was with the pteroq.service file. I had to change /usr/bin/php to /usr/bin/php7.4

    I also had to chown the /var/www/pterodactyl/storage to www-data:www-data. For some reason some of the files were owned by root:root and it was throwing a permission error.

  • wild1145 November 2, 2022 at 6:32 PM

    Selected a post as the best answer.