I need help to solve a problem with a cron running a docker exec command.
After setting up this cron, my server sometimes gets not responding anymore. No web requests handled, no SSH connection possible. I must restart the server to get it back. It usually happens 3 or 4 times per day.
My cron is setup in my host's crontab :
* * * * * docker exec -w /home/current myphpapp-container bash -c "php artisan schedule:run >> storage/logs/schedule.log"
I'm pretty sure the cron is faulty here because I never had this problem before the cron installation and I don't get it when I disable the cron script.
Docker version is "18.06.3-ce".
The container is a "php:8.0-fpm".
OS is "Debian GNU/Linux 8 (jessie)".
I searched into syslog and others but did not find anything interesting. My cron is minute but I don't even see any progressive load increasing along time. I'm a bit stuck...
Do you have any ideas ? Where should I look to find relevant logs ?
Ok, finally, it looks like a "Docker engine 18.06" related problem. I created a new fresh server with OS and Docker engine up to date. Problem is gone.
Related
We are using Laravel with BeansTalkD for queuing in our app. Now I am stuck at a point that this command :
php artisan queue:listen
keeps getting jobs, in other words there are a lot of jobs and I have no idea how to clean the queue.
And the problem is that I ran the beanstalkd using this command:
beanstalkd -z 1024*1024
which does not specify wal directory.
I have been searching for the whole last week on how to clean beanstalk work queue, but found nothing.
Tips
I am running this on Mac OS X Yosemite.
Restarting BeansTalkD service did not solve it
I don't store jobs in DB so flush command is not the one. (I don't know if Laravel does that with me knowing but I don't think so)
I am deleting the jobs when I am done but the app generates a lot of jobs.
If you didn't use -b option then restarting beanstalkd (again without -b) should help.
Now if restarting for some reason doesn't work for you and you're using Laravel 5.x you can consider installing artisan-beans package and use php artisan beans:purge command to clean up your queue.
UPDATE: Since you're on Laravel 4.2 you can
install dependency-free CLI tool beanstool. Here's how install v2.0 on OS X
wget https://github.com/tyba/beanstool/releases/download/v0.2.0/beanstool_v0.2.0_darwin_amd64.tar.gz
tar -xvzf beanstool_v0.2.0_darwin_amd64.tar.gz
cp beanstool_v0.2.0_darwin_amd64/beanstool /usr/local/bin/
and then run this in bash
for i in {1..N}; do beanstool delete -t default --state=ready; done
Change N to the number of jobs you want to delete at once and default to the name of your queue (tube).
If you wonder how many jobs you currently have in the queue run
beanstool stats
Beside the accepted answer I found another solution which is to stop (CTRL+C) the command:
beanstalkd -z 1048576
and start a the command again with the -b option:
beanstalkd -z 1048576 -b ~/btd_data
this also solved the problem
I have encapsulated pdftk (PDF tool kit) as program that can be run inside of a fedora docker image. This allows me to run pdftk on a newer AWS AMI image that does not support pdftk. When replacing pdftk in our PHP program with the docker run command, it works great when running the PHP program from the command line, but when running it as a cron job or as a mailbox command, docker will not run. I have made the cron and mailbox users part of the docker group, checked permissions and paths, but still no joy.
The exec PHP command looks like:
$command = 'docker run -i -t --privileged -v /var/www/mbx/forms/inbox:/workdir -w /workdir/ brnlab/aultman-pdftk ./'.basename($files[$i]).' burst output ./pg_%03d.pdf';
Oddly the return on the $command when running this as a cron or mailbox command is blank, so I am not sure if there is an error or not. It does not appear to hang up. Any ideas on the best way to diagnose the issue further?
I have a jenkins build job of my symfony2 project that uses grunt to start the php built in webserver so that casperjs can run functional tests against it.
To start my webserver I'm using the following command:
php app/console server:start --router=" + __dirname + "/app/config/router_test.php --env=test 0.0.0.0:9001"
However the build fails with the following message:
A process is already listening on http://0.0.0.0:9001.
Thus I have SSHed to the jenkins box and run:
netstat -tln | grep 9001
Only to get no results?!
I have restarted the server and killed all php processes, disabled iptables however none of this seems to work.
This build used to work and in the last change, all that was added were more functional tests.
Has anyone got any ideas why this could be happening?
As commented, the fix that worked for me was to change the workspace directory. Seems to have been a permissions issue with the workspace folder that jenkins created yet a chmod 777 didn't resolve it hence the new workspace folder.
I've tried just about everything to get my cron script to work but am not having any luck. I've been through many mini tutorial several times too! Here's what I'm trying to run...
/usr/bin/php -q /home/username/public_html/yourfilename.php
On cpanel even i am not getting email after running time of my crone job.
thank you
Try this
/usr/bin/php -q /home/username/public_html/yourfilename.php >/dev/null
You need to check below points.
The file location is correct.
check that the crond services running or not. you can check with below commend :
/etc/init.d/crond status
and you should get status running with pid. if you can got it then move on point 3 otherwise. try to restart the cron service via below command:
/etc/init.d/crond restart
and check the logs via below command :
tail -f /var/log/cron
if you getting the cron service working then check your lfd service working on not.
/etc/init.d/lfd status
if its running then check your email proper configure on lfd.
if lfd fine then run below command as root to add cron
crontab -e
give your cron at the end of file with correct format.
sure that time it will work.
if getting any issue in any point. let me know here.
From the basic of php i know that php needs to have some action/request to execute so i am little confused about how to do it. I know it can be done but don't know how.
I want to write a php script which will run in server every 6 hours and update the database info from an api.
More Info:
The server i am currently working is in linux. But i want to know how i can do it in both linux and windows.
UPDATE:
Cron does not find my script. I don't know where is the problem is. I have used this command in my cpanel
0 */6 * * * php public_html/path_to_dir/file_to_run.php
I have setup the cron so cPanel send me email. The email i am getting is showing some error.
/bin/sh: 0: command not found
Looking forward to your help.
You need to have something run the script on a timer. This is typically going to be cron (on UNIX based systems such as Linux, OS X, BSD, etc) or Windows Task Schedular (on Windows).
You can use crontab to schedule a process in Unix.
I assume that you're using a Linux based S.O.
Install the php5-cli package as
root with apt-get install php5-cli
(or your pkg manager).
Write and test your script
with the PHP CLI, php
filename.php.
Login as selected
user and set up a crontab using
crontab -e
Write the crontab line: * */6 * * * php /full-path/filename.php
/var/log/messages should log the crontab activities.