4

It seems Linux Mint 19.3 Tricia Cinnamon wants to clear out PHP session files every half-hour.

How do I:

  • Remove this task from the scheduler's awareness, and
  • Not have to reboot the computer to do so.

I found the crontab file at /etc/cron.d/php.

I edited the file by making the relevant line a comment. I expected that now that there is no information in this crontab file that would establish when it should trigger the task, not even the scheduler(?) would keep aware of it.

# 09,39 *     * * *     root   [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi

The cron process(?) noticed the new file timestamp and reloaded the file (as seen in the syslog).

But the scheduler is still logging in syslog.

Mar  6 01:09:07 BrownBunny systemd[1]: Starting Clean php session files...
Mar  6 01:09:08 BrownBunny systemd[1]: Started Clean php session files.

(which I do not know where to look for those phrases).

I tried the command:

sudo service cron reload

The PHP session files were still cleaned up.

I can move the php crontab file out of cron.d. Considering the above, would this even work?

Notes: I am cross-posting this question from LinuxMint Forums:

Note: This question is copied over from Ask Ubuntu because they consider it not really applicable to Ubuntu.

2
  • 2
    That cron will not run if you have systemd available, as the test if [ ! -d /run/systemd/system ] would fail. This is because systemd has it's own method to schedule the PHP session cleanup, and your posted log mentioned that the command was run by systemd and not cron. Check systemctl status phpsessionclean or systemctl status phpsessionclean.timer, I do not recall the exact name and do not have a compatible system in front of me. Mar 6 '20 at 21:39
  • @GracefulRestart - Thank you! Using systemctl to stop and disable both phpsessionclean.service and phpsessionclean.timer worked. If you would, write this up as an answer and I will accept it. Again, thank you.
    – bsmither
    Mar 7 '20 at 8:40
4

The phpsessionclean scripts as delivered by upstream Debian will either use cron if there is no systemd present, or will use systemd for scheduling if it is available.

This is apparent in the cronjob test if [ ! -d /run/systemd/system ] which checks if systemd has been initialized on this system.

When systemd is available, phpsessionclean has a service unit (phpsessionclean.service) in addition to a timer unit (phpsessionclean.timer). Stopping and disabling both of these, should stop the scheduled task from running within systemd:

systemctl stop phpsessionclean.service
systemctl disable phpsessionclean.service
systemctl stop phpsessionclean.timer
systemctl disable phpsessionclean.timer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.