I have tons of scripts wich run in background via cronjob and many frontend stuff happening. Some weeks ago we had a system fatal error where our mounted drives have been fried and our cronjob got stuck... we had to restart the whole system and even go so far to restart the rack oldstyle.
The problem is that our debian instance was partually "kaput".
Some of the files got a total permision lock and hat no permisioins at all, when you run ls /sys/crontab/lock it had no permisions but the cronjob was still runing and making tons of problems.
The worst part is tht the php was still runing and the mysql server was up and runing, even without the file system permisions(And was making orders without the files... BIG problem). Talk about to reliable.
Now my question is is there a way if i can detect if a debian system is working?
Except trying touch on every script run, or writing locks in the DB.
Related
I have got a cron in PHP that crash without any log into the php_errors on a debian. Most of the time (99% of the time), it's work fine and I have no problem with it.
But randomly, it just stop and I have nothing in any log on the server. I have got the issue on 2 different server (with very similar install), always when the load increase.
I installed systemd-coredump on the server because I suspected a segfault into one of php library (the script is complex and make a lot of webservices call) but it didn't log anything on the last crash.
Out of memory are well log into the php_errors, so it doesn't seem to be the problem.
What can I do to gather any logs that can give me a hint on what happen and why my pid just stop ?
My webhost recently updated something that has shut down the abblity to run cron jobs for an as of yet undefined amount of time. Which wouldn't be a problem, save for the fact that two hours before they did, I had released my project for beta testing.
I've currently got a tab open on my computer with some script on my local server that is updating the live server via an autorefresher. however, I don't feel it would be a good idea to keep my laptop running 24/7 until they fix this error. so I was wondering if there is any wya possible to "Fake" a cron job in php?
I dont know why everytime that I tried to make the .bashrc run a command affects my SFTP connection from other softwares...
This time Im just trying to start my apache server automatically because the servers restarts every day at midnight so, Its kinda annoying to go to the command line and restart my apache server.. big fail but I guess, I cant do much about my school policies or whatever they do with their servers..
What I was simply adding at the end of this file .bashrc it was this
~/apache/bin/apachectl start
but this simple command creates immediately conflict with my connection SFTP using other softwares.. So, Im not sure which is the proper way to do this..
You really really do not want to put this in your .bashrc. The bashrc gets executed for EVERY shell you start. You could potentially be running this command hundreds of times per login session.
Read the bash man page and figure out which of the various start up files you want this in, my guess would be the .bash_profile script. Even then it seems very odd to me...
http://www.linuxfromscratch.org/blfs/view/6.3/postlfs/profile.html
However, to avoid the sftp problem you need to make sure that your .bashrc script does not write anything to STDOUT. If you run a commmand inside it redirect the output to /dev/null or a logfile. In general it's a very bad idea to run any commands in the .bashrc, you should mostly be setting configuration variables.
Running commands in .bash_profile is sort of ok, but in the long run it almost always causes more problems that it solves.
I have a php file which pulls some data from external API's, and I want to schedule it to do so every few hours (or every few days). Some googleing led me to "scheduled tasks", but it seems I need to be running my own server to do it?
So far, all the PHP and MySQL I've done have been very simple form-filling, so I'm a little lost. Do I need to turn a computer into a server to do this, or should I look into hosts that allow you to run scripts? I'm not exactly sure what I'm looking for.
Side-question: how would I be able to prevent someone else from running the PHP script (therefor making tons of API calls)?
How are you running the script now? Windows or Linux? Linux is a no-brainer with cron: on a PHP-enabled server simply drop the PHP script somewhere, edit the crontab and away you go!
Ex. for every 2 hours
0 */2 * * * /usr/local/bin/php /path/to/script.php
Edit Re: Mac
launchd is apparently the preferred method to run scheduled tasks but I understand that OS X has cron capabilities as well being a UNIX derivative.
If you have a reasonably busy web server, you can simply check every time how long it has been since the last time you ran the script. If more than two hours, run it.
Just make sure to update the time and run the script atomically so you don't launch several copies of the script. You can do this with a file that contains the last time the script was run that you lock while you check and update it.
cronjobs are made for it... You can check the Cron Jobs in cpanel..
I am assuming your website is launched in Linu environment
http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
http://man.cx/cron
You can find much more exlaination about the Background Process
http://www.fijiwebdesign.com/blog/create-a-background-process-on-the-server-with-php.html
We have several CRON jobs running on our apache / whm server. We are using php. The scripts all work completely fine when run from the browser.
The cron will throw back errors like: unable to include files (even when giving the absolute path).
Results will also vary, corrupting output files etc. I am really baffled, as sometimes the crons work fine as well. Seems really intermittent and they work every time perfectly when executed from the browser.
Any help would be appreciated, cheers.
As everyone has pointed out, PHP CLI and the PHP Apache Module are separate software and they have separate configuration files.
Rather than set the crontab up on the root cron tab, make sure all your permissions are correct. Debug with the user they will run from cron as. Assuming you are running Linux, you can use
sudo -i -u username
for this.