Skip to content

Instantly share code, notes, and snippets.

@paulredmond
Last active April 9, 2017 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulredmond/596c03a12d49a617e46f4cf32fcf9422 to your computer and use it in GitHub Desktop.
Save paulredmond/596c03a12d49a617e46f4cf32fcf9422 to your computer and use it in GitHub Desktop.
Documenting different scenarios the Laravel scheduler runs in docker as a bash entrypoint - reference repo https://github.com/bitpressio/laravel-docker
# when you run a 1 minute schedule command that takes more than 1 minute using `withoutOverlapping()`
# Running the scheduler in the background so sleep hits right away...
# # Run the scheduler
# while [ true ]
# do
# php artisan schedule:run --verbose --no-interaction &
# sleep 60
# done
#
# Processes
#
# During a scheduler run
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 20060 2828 ? Ss 03:42 0:00 /bin/bash /opt/bin/entrypoint.sh
root 25 0.0 0.0 20252 3208 ? Ss 03:44 0:00 bash
root 32 0.0 0.0 20252 3276 ? Ss 03:44 0:00 bash
root 129 0.0 0.0 4272 684 ? S+ 03:46 0:00 tail -f storage/logs/laravel.log
root 166 0.1 0.3 119604 24748 ? S 03:46 0:00 php artisan schedule:run --verbose --no-interaction
root 174 0.0 0.0 4336 716 ? S 03:46 0:00 sh -c '/usr/local/bin/php' 'artisan' cron-test > '/dev/null' 2>&1
root 175 0.1 0.3 119604 24724 ? S 03:46 0:00 /usr/local/bin/php artisan cron-test
root 237 0.0 0.0 4236 684 ? S 03:47 0:00 sleep 60
root 244 0.0 0.0 17500 2056 ? R+ 03:47 0:00 ps aux
# After scheduler is done running without overlap
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 20060 2828 ? Ss 03:42 0:00 /bin/bash /opt/bin/entrypoint.sh
root 25 0.0 0.0 20252 3208 ? Ss 03:44 0:00 bash
root 32 0.0 0.0 20252 3276 ? Ss 03:44 0:00 bash
root 129 0.0 0.0 4272 684 ? S+ 03:46 0:00 tail -f storage/logs/laravel.log
root 237 0.0 0.0 4236 684 ? S 03:47 0:00 sleep 60
root 278 0.0 0.0 17500 2052 ? R+ 03:48 0:00 ps aux
# Logs
[2017-04-09 03:42:40] local.INFO: Starting cron test, sleeping for 80 seconds 2017-04-09T03:42:40+00:00
[2017-04-09 03:44:00] local.INFO: Ending cron test2017-04-09T03:44:00+00:00
[2017-04-09 03:44:40] local.INFO: Starting cron test, sleeping for 80 seconds 2017-04-09T03:44:40+00:00
[2017-04-09 03:46:00] local.INFO: Ending cron test2017-04-09T03:46:00+00:00
# When you run the scheduler in the background
# while [ true ]
# do
# php artisan schedule:run --verbose --no-interaction &
# sleep 60
# done
root@b04504f8db2e:/srv/app# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 20060 2872 ? Ss 03:31 0:00 /bin/bash /opt/bin/entrypoint.sh
root 17 0.0 0.0 20252 3240 ? Ss 03:32 0:00 bash
root 24 0.0 0.0 20252 3216 ? Ss 03:32 0:00 bash
root 30 0.0 0.0 4272 744 ? S+ 03:32 0:00 tail -f storage/logs/laravel.log
root 54 0.1 0.3 119604 24688 ? S 03:33 0:00 php artisan schedule:run --verbose --no-interaction
root 62 0.0 0.0 4336 788 ? S 03:33 0:00 sh -c '/usr/local/bin/php' 'artisan' cron-test > '/dev/null' 2>&1
root 63 0.1 0.3 119604 24848 ? S 03:33 0:00 /usr/local/bin/php artisan cron-test
root 72 1.0 0.3 119604 24756 ? S 03:34 0:00 php artisan schedule:run --verbose --no-interaction
root 73 0.0 0.0 4236 680 ? S 03:34 0:00 sleep 60
root 80 0.0 0.0 4336 788 ? S 03:34 0:00 sh -c '/usr/local/bin/php' 'artisan' cron-test > '/dev/null' 2>&1
root 81 0.8 0.3 119604 24552 ? S 03:34 0:00 /usr/local/bin/php artisan cron-test
root 82 0.0 0.0 17500 2100 ? R+ 03:34 0:00 ps aux
# After the first scheduler exits, the next one is still running...
root@b04504f8db2e:/srv/app# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 20060 2872 ? Ss 03:31 0:00 /bin/bash /opt/bin/entrypoint.sh
root 17 0.0 0.0 20252 3240 ? Ss 03:32 0:00 bash
root 24 0.0 0.0 20252 3216 ? Ss 03:32 0:00 bash
root 30 0.0 0.0 4272 744 ? S+ 03:32 0:00 tail -f storage/logs/laravel.log
root 93 0.4 0.3 119604 24828 ? S 03:36 0:00 php artisan schedule:run --verbose --no-interaction
root 94 0.0 0.0 4236 708 ? S 03:36 0:00 sleep 60
root 101 0.0 0.0 4336 744 ? S 03:36 0:00 sh -c '/usr/local/bin/php' 'artisan' cron-test > '/dev/null' 2>&1
root 102 0.3 0.3 119604 24860 ? S 03:36 0:00 /usr/local/bin/php artisan cron-test
root 121 0.0 0.0 17500 2072 ? R+ 03:37 0:00 ps aux
# Logging the console commands
[2017-04-09 03:33:49] local.INFO: Starting cron test, sleeping for 80 seconds 2017-04-09T03:33:49+00:00
[2017-04-09 03:34:09] local.INFO: Ending cron test 2017-04-09T03:34:09+00:00
[2017-04-09 03:34:49] local.INFO: Starting cron test, sleeping for 80 seconds 2017-04-09T03:34:49+00:00
[2017-04-09 03:35:09] local.INFO: Ending cron test 2017-04-09T03:35:09+00:00
[2017-04-09 03:35:49] local.INFO: Starting cron test, sleeping for 80 seconds 2017-04-09T03:35:49+00:00
[2017-04-09 03:36:09] local.INFO: Ending cron test 2017-04-09T03:36:09+00:00
# When you run a 1 minute schedule command that takes more than 1 minute using `withoutOverlapping()`
#
# Example:
# $schedule->command('cron-test')
# ->withoutOverlapping();
#
# while [ true ]
# do
# php artisan schedule:run --verbose --no-interaction # run in the foreground
# sleep 60
# done
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 20060 2772 ? Ss 03:19 0:00 /bin/bash /opt/bin/entrypoint.sh
root 7 0.1 0.3 119600 24848 ? S 03:19 0:00 php artisan schedule:run --verbose --no-interaction
root 14 0.0 0.0 4336 724 ? S 03:19 0:00 sh -c '/usr/local/bin/php' 'artisan' cron-test > '/dev/null' 2>&1
root 15 0.1 0.3 119604 24812 ? S 03:19 0:00 /usr/local/bin/php artisan cron-test
root 16 0.0 0.0 20252 3216 ? Ss 03:19 0:00 bash
root 46 0.0 0.0 17500 2104 ? R+ 03:20 0:00 ps aux
root@9ef97570a5b6:/srv/app# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 20060 2772 ? Ss 03:19 0:00 /bin/bash /opt/bin/entrypoint.sh
root 16 0.0 0.0 20252 3216 ? Ss 03:19 0:00 bash
root 47 0.0 0.0 4236 716 ? S 03:20 0:00 sleep 60
root 48 0.0 0.0 17500 1960 ? R+ 03:20 0:00 ps aux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment