<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cron on Daniel Zhang</title><link>https://zhangdapeng.dev/tags/cron/</link><description>Recent content in Cron on Daniel Zhang</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Tue, 17 Nov 2026 14:30:00 +0800</lastBuildDate><atom:link href="https://zhangdapeng.dev/tags/cron/index.xml" rel="self" type="application/rss+xml"/><item><title>Managing Crontab in CentOS Docker Containers: Fixing crond and systemctl Issues</title><link>https://zhangdapeng.dev/p/centos-docker-crond-crontab-management/</link><pubDate>Tue, 17 Nov 2026 14:30:00 +0800</pubDate><guid>https://zhangdapeng.dev/p/centos-docker-crond-crontab-management/</guid><description>&lt;img src="https://zhangdapeng.dev/p/centos-docker-crond-crontab-management/cover.png" alt="Featured image of post Managing Crontab in CentOS Docker Containers: Fixing crond and systemctl Issues" /&gt;&lt;h2 id="1-background"&gt;1. Background
&lt;/h2&gt;&lt;p&gt;On a traditional CentOS system, modifying or adding Crontab jobs usually does not require restarting the &lt;code&gt;crond&lt;/code&gt; service. The Cron daemon periodically checks for configuration changes and automatically loads updated schedules.&lt;/p&gt;
&lt;p&gt;However, things can be different when working inside a Docker container.&lt;/p&gt;
&lt;p&gt;While modifying scheduled tasks inside a CentOS Docker container, I initially tried to reload the Cron service using:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;systemctl reload crond.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But the command returned the following error:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Failed to get D-Bus connection: Operation not permitted
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I then tried the traditional &lt;code&gt;service&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;service crond restart
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Unfortunately, it failed with a similar error:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Redirecting to /bin/systemctl restart crond.service
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Failed to get D-Bus connection: Operation not permitted
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This indicated that the problem was not related to the Crontab configuration itself, but rather to how services are managed inside Docker containers.&lt;/p&gt;
&lt;h2 id="2-why-systemctl-does-not-work-inside-docker-containers"&gt;2. Why systemctl Does Not Work Inside Docker Containers
&lt;/h2&gt;&lt;p&gt;On traditional CentOS 7 systems, &lt;code&gt;systemd&lt;/code&gt; is usually the init system running as PID 1. It manages system services and handles operations such as starting, stopping, and restarting background processes.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;systemctl restart crond
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;systemctl status crond
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;systemctl reload crond
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These commands depend on systemd and its D-Bus communication mechanism.&lt;/p&gt;
&lt;p&gt;Docker containers, however, typically run with a much smaller process environment. They do not normally start a complete systemd environment.&lt;/p&gt;
&lt;p&gt;You can check the container&amp;rsquo;s PID 1 process using:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ps -p &lt;span class="m"&gt;1&lt;/span&gt; -o pid,ppid,cmd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You may see output similar to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PID PPID CMD
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1 0 /sbin/docker-init -- /bin/bash -c ...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This indicates that PID 1 is not systemd.&lt;/p&gt;
&lt;p&gt;As a result:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;systemctl&lt;/code&gt; cannot communicate with a running systemd instance.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;service&lt;/code&gt; command in some CentOS images redirects service operations to &lt;code&gt;systemctl&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Traditional Linux service management commands may not work inside containers.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;The solution is to run the &lt;code&gt;crond&lt;/code&gt; binary directly or manage it through a process manager such as Supervisor.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id="3-starting-crond-manually-inside-a-docker-container"&gt;3. Starting crond Manually Inside a Docker Container
&lt;/h2&gt;&lt;h3 id="31-check-whether-crond-is-running"&gt;3.1 Check Whether crond Is Running
&lt;/h3&gt;&lt;p&gt;First, check whether the Cron daemon is already running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ps -ef &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;&amp;#39;[c]rond&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Using &lt;code&gt;[c]rond&lt;/code&gt; prevents grep from matching its own process.&lt;/p&gt;
&lt;p&gt;If there is no output, no matching crond process is currently running.&lt;/p&gt;
&lt;p&gt;One important detail: seeing the word &lt;code&gt;crond&lt;/code&gt; inside the PID 1 command line does not mean the Cron daemon is actually running.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;root 1 0 ... /bin/bash -c /usr/sbin/crond ...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This only shows that the startup command contains the string &lt;code&gt;crond&lt;/code&gt;. It does not prove that &lt;code&gt;/usr/sbin/crond&lt;/code&gt; has successfully started as an independent process.&lt;/p&gt;
&lt;h3 id="32-start-crond-directly"&gt;3.2 Start crond Directly
&lt;/h3&gt;&lt;p&gt;On CentOS containers, you can start the Cron daemon directly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/sbin/crond
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Alternatively:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crond
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By default, crond daemonizes itself and runs in the background.&lt;/p&gt;
&lt;p&gt;If you want to run it in the foreground, which is useful when managing it through Docker or Supervisor, use:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/sbin/crond -n
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;-n&lt;/code&gt; option prevents crond from daemonizing.&lt;/p&gt;
&lt;h3 id="33-verify-that-crond-started-successfully"&gt;3.3 Verify That crond Started Successfully
&lt;/h3&gt;&lt;p&gt;Run the following command again:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ps -ef &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;&amp;#39;[c]rond&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A successful startup should produce output similar to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;root 10 1 0 ... /usr/sbin/crond
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This confirms that the Cron daemon is running.&lt;/p&gt;
&lt;h3 id="34-stop-and-restart-crond"&gt;3.4 Stop and Restart crond
&lt;/h3&gt;&lt;p&gt;If you genuinely need to restart crond, you can use:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Stop the existing crond process&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pkill crond
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Start crond again&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/sbin/crond
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Verify the process&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ps -ef &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;&amp;#39;[c]rond&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Be careful when using &lt;code&gt;pkill crond&lt;/code&gt;, especially in production environments. It terminates matching processes, so verify the target process before stopping it.&lt;/p&gt;
&lt;p&gt;In most cases, restarting crond is unnecessary when you only modify scheduled tasks.&lt;/p&gt;
&lt;h2 id="4-do-you-need-to-restart-crond-after-updating-crontab"&gt;4. Do You Need to Restart crond After Updating Crontab?
&lt;/h2&gt;&lt;p&gt;This is the most important point from this troubleshooting process.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usually, no.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The Cron daemon periodically checks Crontab configurations and automatically reloads changes.&lt;/p&gt;
&lt;p&gt;Therefore, whether you are working on a traditional CentOS server or inside a Docker container, you generally only need to update the configuration.&lt;/p&gt;
&lt;h3 id="41-edit-the-current-users-crontab"&gt;4.1 Edit the Current User&amp;rsquo;s Crontab
&lt;/h3&gt;&lt;p&gt;Run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crontab -e
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For example, to execute a Laravel scheduled task every day at 3:00 AM:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-cron" data-lang="cron"&gt;0 3 * * * /usr/local/bin/php /var/www/html/artisan schedule:run
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Save and exit. The updated configuration will be picked up automatically.&lt;/p&gt;
&lt;h3 id="42-list-existing-cron-jobs"&gt;4.2 List Existing Cron Jobs
&lt;/h3&gt;&lt;p&gt;To view the current user&amp;rsquo;s scheduled tasks:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crontab -l
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="43-import-crontab-from-a-file"&gt;4.3 Import Crontab from a File
&lt;/h3&gt;&lt;p&gt;If you already have a Crontab configuration file, you can import it directly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crontab /path/to/cronfile
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; This replaces the current user&amp;rsquo;s existing Crontab configuration rather than appending new entries.&lt;/p&gt;
&lt;p&gt;If you need to add tasks without losing existing ones, back up and merge the configurations before importing them.&lt;/p&gt;
&lt;h3 id="44-system-level-cron-jobs"&gt;4.4 System-Level Cron Jobs
&lt;/h3&gt;&lt;p&gt;System-wide scheduled tasks are commonly configured in:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/etc/crontab
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or in files under:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/etc/cron.d/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These configurations also generally do not require manually restarting crond.&lt;/p&gt;
&lt;p&gt;One important difference is that system-level Crontab entries include an additional field specifying the execution user.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-cron" data-lang="cron"&gt;0 3 * * * root /usr/local/bin/php /var/www/html/artisan schedule:run
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="5-why-does-crond-stop-running-after-a-docker-container-restart"&gt;5. Why Does crond Stop Running After a Docker Container Restart?
&lt;/h2&gt;&lt;p&gt;Starting crond manually with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/sbin/crond
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;solves the immediate problem, but introduces another issue.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A manually started background process is not automatically registered as part of the container&amp;rsquo;s startup configuration.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When the container stops and starts again, crond will not necessarily be started unless the Docker startup command explicitly launches it.&lt;/p&gt;
&lt;p&gt;For containers that need to run scheduled tasks continuously, crond should be managed by a process manager.&lt;/p&gt;
&lt;p&gt;Since this container already uses Supervisor, we can use it to manage crond.&lt;/p&gt;
&lt;h3 id="51-configure-supervisor-to-manage-crond"&gt;5.1 Configure Supervisor to Manage crond
&lt;/h3&gt;&lt;p&gt;Edit the Supervisor configuration file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vi /etc/supervisor/supervisord.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add the following configuration:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;[program:crond]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/sbin/crond -n&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;autostart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;autorestart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;startsecs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;startretries&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;priority&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;stdout_logfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/var/log/supervisor/crond.log&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;stderr_logfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/var/log/supervisor/crond-error.log&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Configuration details:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Parameter&lt;/th&gt;
					&lt;th&gt;Description&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;command&lt;/td&gt;
					&lt;td&gt;Runs crond in the foreground&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;autostart&lt;/td&gt;
					&lt;td&gt;Automatically starts crond when Supervisor starts&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;autorestart&lt;/td&gt;
					&lt;td&gt;Restarts crond if the process exits&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;startsecs&lt;/td&gt;
					&lt;td&gt;Minimum time required to consider startup successful&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;startretries&lt;/td&gt;
					&lt;td&gt;Number of startup retries&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;priority&lt;/td&gt;
					&lt;td&gt;Controls process startup order&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;stdout_logfile&lt;/td&gt;
					&lt;td&gt;Standard output log file&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;stderr_logfile&lt;/td&gt;
					&lt;td&gt;Standard error log file&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The &lt;code&gt;-n&lt;/code&gt; option is particularly important.&lt;/p&gt;
&lt;p&gt;Supervisor needs to monitor the actual crond process. Running it in the foreground prevents it from daemonizing and leaving Supervisor monitoring the wrong process.&lt;/p&gt;
&lt;h3 id="52-reload-supervisor-configuration"&gt;5.2 Reload Supervisor Configuration
&lt;/h3&gt;&lt;p&gt;If Supervisor is already running, execute:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;supervisorctl reread
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;supervisorctl update
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check the process status:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;supervisorctl status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also manage crond individually:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Start crond&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;supervisorctl start crond
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Restart crond&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;supervisorctl restart crond
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this configuration, you no longer need to manually run &lt;code&gt;pkill&lt;/code&gt; or &lt;code&gt;/usr/sbin/crond&lt;/code&gt; to manage the process.&lt;/p&gt;
&lt;p&gt;Note that &lt;code&gt;supervisorctl&lt;/code&gt; requires Supervisor to be running and its control interface to be configured correctly.&lt;/p&gt;
&lt;h2 id="6-common-crontab-troubleshooting-issues-in-docker"&gt;6. Common Crontab Troubleshooting Issues in Docker
&lt;/h2&gt;&lt;p&gt;If crond is running but scheduled tasks are still not executing, check the following items.&lt;/p&gt;
&lt;h3 id="61-verify-the-crond-process"&gt;6.1 Verify the crond Process
&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ps -ef &lt;span class="p"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;&amp;#39;[c]rond&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make sure the Cron daemon is actually running.&lt;/p&gt;
&lt;h3 id="62-verify-the-crontab-configuration"&gt;6.2 Verify the Crontab Configuration
&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crontab -l
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check that the schedule expression is valid and that the task belongs to the expected user.&lt;/p&gt;
&lt;h3 id="63-use-absolute-paths"&gt;6.3 Use Absolute Paths
&lt;/h3&gt;&lt;p&gt;Cron jobs usually run with a much smaller environment than an interactive shell.&lt;/p&gt;
&lt;p&gt;For example, avoid relying on the following command:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-cron" data-lang="cron"&gt;* * * * * php /var/www/html/artisan schedule:run
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Instead, specify the complete executable path:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-cron" data-lang="cron"&gt;* * * * * /usr/local/bin/php /var/www/html/artisan schedule:run
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can find the PHP executable path using:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;which php
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This helps avoid problems caused by missing environment variables or an incomplete PATH.&lt;/p&gt;
&lt;h3 id="64-check-cron-logs"&gt;6.4 Check Cron Logs
&lt;/h3&gt;&lt;p&gt;On CentOS, Cron logs are commonly available at:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tail -f /var/log/cron
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the log file does not exist, check whether rsyslog is running and whether the container image is configured to collect Cron logs.&lt;/p&gt;
&lt;p&gt;You can also redirect job output to a dedicated log file:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-cron" data-lang="cron"&gt;* * * * * /usr/local/bin/php /var/www/html/artisan schedule:run &amp;gt;&amp;gt; /var/log/laravel-cron.log 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This makes it easier to identify execution errors.&lt;/p&gt;
&lt;h3 id="65-check-pam-configuration"&gt;6.5 Check PAM Configuration
&lt;/h3&gt;&lt;p&gt;Some CentOS container environments may encounter PAM session initialization problems.&lt;/p&gt;
&lt;p&gt;For example, if logs contain errors related to &lt;code&gt;pam_loginuid.so&lt;/code&gt;, inspect the Cron PAM configuration:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/pam.d/crond
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In restricted container environments, &lt;code&gt;pam_loginuid.so&lt;/code&gt; may fail because the container cannot access the required kernel interface.&lt;/p&gt;
&lt;p&gt;However, you should not modify PAM configuration without first confirming the actual error.&lt;/p&gt;
&lt;p&gt;If logs confirm that this module is causing the problem, evaluate whether adjusting the PAM configuration is appropriate for your container environment and security requirements.&lt;/p&gt;
&lt;h2 id="7-conclusion"&gt;7. Conclusion
&lt;/h2&gt;&lt;p&gt;The main issue in this troubleshooting process was not an incorrectly configured Crontab. It was the difference between traditional Linux service management and Docker&amp;rsquo;s container-based process model.&lt;/p&gt;
&lt;p&gt;Here are the key takeaways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Docker containers typically do not run systemd, so &lt;code&gt;systemctl&lt;/code&gt; is generally unavailable.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;service&lt;/code&gt; command in some CentOS images redirects operations to &lt;code&gt;systemctl&lt;/code&gt;, causing the same failure.&lt;/li&gt;
&lt;li&gt;You can start the Cron daemon directly using &lt;code&gt;/usr/sbin/crond&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Modifying a user&amp;rsquo;s Crontab usually does not require restarting crond.&lt;/li&gt;
&lt;li&gt;Manually started crond processes are not guaranteed to survive container restarts.&lt;/li&gt;
&lt;li&gt;If your container already uses Supervisor, configure crond as an independently managed process.&lt;/li&gt;
&lt;li&gt;If scheduled tasks fail, check the process, Crontab configuration, executable paths, and logs before modifying PAM settings.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Final Recommendation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For Docker containers that need to run scheduled tasks continuously, avoid relying on manually starting &lt;code&gt;/usr/sbin/crond&lt;/code&gt; after entering the container.&lt;/p&gt;
&lt;p&gt;Instead, integrate crond into a process manager such as Supervisor. This ensures that Cron starts automatically when the container starts and can be restarted if the process exits unexpectedly.&lt;/p&gt;
&lt;p&gt;This approach makes scheduled tasks more reliable and easier to maintain in long-running Docker containers.&lt;/p&gt;</description></item></channel></rss>