Drupal: can I setup cron with absolute paths? - drupal

I need to setup cron on my ubuntu server. I have several Drupal websites (with different domains).
In the drupal.org help pages, it is suggested to use the domain http://www.example.com/cron.php
However, I was wondering what to do if I have multiple domains ? Should I add multiple lines for each website ??
Also, what happen if I'm hiding the website using a subdomain while development ? Isn't better to specify the Drupal absolute path on the server instead ?
Can I use instead:
0 * * * * wget -O - -q -t 1 /var/www/drupal/cron.php
?
thanks

When to run
Yes, you want to have one entry per line. Unless the output of errors or simliar are prefixed with what site they came from, you would have no way of knowing what site failed.
You should also offset when each sites cron.php is executed, this is more important if you have a larger number of sites.
Trigger
You can call /var/www/drupal/cron.php without the webserver, although you need to specify the path to PHP and have your script as the argument, not use wget. What this path is will differ depending on your system. Try which php in your shell to see where it is.
$ which php
/usr/bin/php
So, your crontab could end up looking like this:
0 * * * * /usr/bin/php /var/www/drupal/cron.php
30 * * * * /usr/bin/php /var/www/other_drupal_site/cron.php
The first one is started every hh:00 and the second one hh:30.
It is mentioned in http://drupal.org/cron that you can execute the script locally, search for /usr/bin/php on the page to go there (didn't find an anchor).

Use drush instead. here's how to run drush for multi-site,
http://blog.thetajoin.com/content/drush-multisite-cron

Related

How to run cron job automatically without any action in wordpress?

I have used wp_schedule_event but this is not full my requirements.It can be triggered on any click or reload the page.
How can i create cron job that automatically trigger on a specific time without any action in wordpress.
The only way, as far as I know is to use the cron ability of your server.
For example, in Red Hat based distributions such as CentOS, crontab files are stored in the /var/spool/cron directory, while on Debian and Ubuntu files are stored in the /var/spool/cron/crontabs directory. Open crontab file and write something like:
* * * * * php /var/www/html/your-website/your-cron.php
This will execute the file your-cron.php every minute.
Note: Although you can edit the user crontab files manually, it is recommended to use the crontab command.

Change Jenkins basepath

I'm trying to serve a stock jenkins installation (on Amazon Linux AMI) thru myjenkinsinstance:8080/jenkins (rather than myjenkinsinstance:8080), and then proxy this with e.g. Nginx (over HTTP).
This question has been 'answered' before, but the solution doesn't seem to be relevant anymore.
#admins I would prefer to comment on that thread (specifically this 'answer'), rather than opening a duplicate, but I am not allowed to, per my 'reputation' score (as my comment would not be a solution at all, but further request for help).
From the closest thing to an answer I've seen:
Go to Jenkins Home Directory ( I have mine in C:\Jenkins)
Edit jenkins.xml
Add this --prefix=/jenkins to the end of the argument as show below and restart the jenkins service ALL worked OK for me !
Example : <arguments>-Xrs-Xmx256mDhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --prefix=/jenkins</arguments>
Open Url http://localhost:8080/jenkins this should bring up the home page of jenkins
there is no 'jenkins.xml' in the $JENKINS_HOME directory, but there is a config.xml
there is no <arguments/> entry in the config.xml
there seems to be no other configuration for the initial installation
There's also a 'Jenkins Location > Jenkins URL' setting in the "Configure System" settings (myjenkinsinstance/configure), but modifying this seems to have no noticeable affect.
The end goal would be to automate this installation via e.g. CloudFormation (as part of the EC2's UserData).
Any suggestions would be greatly appreciated.
On your linux system, you need to find the jenkins default config file located at
/etc/default/jenkins
and then add the following arguments according to your requirements. This is a rough idea.
JENKINS_ARGS="--webroot=/var/cache/jenkins/war --prefix=/jenkins
--httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT"
This should work most likely. If it doesnt, pls update your answer with the current arguments present. This works fine for Debian/Ubuntu.
Also you are running jenkins on your windows machine or linux?
So my 'solution' was to use sed and insert some lines into /etc/nginx/nginx.conf and /etc/init.d/jenkins.
e.g.
sed -i '/^ location \/ {/aproxy_pass http://127.0.0.1:8080/;' /etc/nginx/nginx.conf
sed -i '/^PARAMS=/ s/"$/ --prefix=\/jenkins"/' /etc/init.d/jenkins
I highly doubt this is anything near a 'best practice', but it seems to work for now (what happens were I to update with yum... I'm not sure, but the plan is to back the instance with an Elastic Filesystem, which hopefully will allow us to consider the jenkins instance ephemeral, anyway).

How do I add a cronjob to a makefile?

How do I add a cronjob to a makefile so when I compile a C program, I add a cron job to crontab so that program gets executed every minute:
Cron job I am trying to add:
* * * * * /Users/jenna/desktop/ && ./myProgram command_line_arg1
how do I add this to a make file ?
I believe it is a bad idea to add a crontab job from a Makefile. Adding a cron job is a sysadmin issue. Compiling your program is for a developer's hat.
If you insist on doing that, you might use crontab -l > mycrontab to list the current crontab jobs, then appending with
echo '* * * * * cd /Users/jenna/desktop/ && ./myProgram command_line_arg1' \
>> mycrontab
you probably want to make that more robust (perhaps use grep or awk) to avoid the appending if the crontab already contains that. BTW, you probably want to use $HOME/Desktop (and even that might not work on a French configured user, it would be $HOME/Bureau).
Then, set the new crontab with crontab mycrontab
At last, running something every minute seems suspicious to me. What is your program doing?
I would suggest to at the very least prompt the user before updating his/her crontab file....
Perhaps you want the at command....

Can I use wp-cli to get the Wordpress installation directory?

Can I use wp-cli to return a value for the local Wordpress installation root directory?
Ideally I'd like a wp-cli command like "wp pathname" that returns "user/myname/sites/project_a" when invoked from inside Projects A's installation, and "user/myname/sites/project_b" when invoked inside Project B.
I'm writing a bash script to dump a Wordpress database and do a little post-processing on it. I'm calling on wp-cli to make the dump; I'd also like to use wp-cli to find the pathname for the installation so that I can guarantee than when invoked anywhere in the current installation the dumpfile will always be written to "some/path/to/project_name/dbdumps/". I can't find anything in the documentation about install directory.
wp-cli seems like the right tool for the job because it's Wordpress aware, but I am happy to use some other tool that is capable of discovering my install directory; perhaps a creative and elegant use of the find command, or a way to report the value of Wordpress's FTP_BASE variable?
I ended up doing this with bash, not wp-cli, by using BASH_SOURCE.
There doesn't appear to be a way to do this from within wp-cli itself, but since my script is always running from inside the Wordpress install directory it doesn't matter — I can just find my script's location.

Issues with cron

I'm really stuck. I've used cron on many machines, but I simply can not get it to work on an Ubuntu server. I've tried everything I can think over the weekend and I'm baffled. I'm hoping someone can help me out.
I can verify that cron is running via pgrep cron. However, pgrep crond returns nothing. I am trying to run a simple shell script (test.sh) with cron:
#!/bin/sh
/usr/bin/touch /home/jarvis/test.txt
I have run chmod +x on the shell script and my crontab looks like this:
01 * * * * /home/jarvis/test.sh
I also have a new line ending after the line.
Try redirecting all output to a file and see if there are any error messages that can help you diagnose the problme, i.e.
01 * * * * /home/jarvis/test.sh > /tmp/jarvis_test.log 2>&1
Also, if you created any of those files from a windows environment, don't forget dos2unix filename
edit
My point is that you won't know for what your script is doing in the crontab environment unless you see if it is outputing an error message. Error messages also go to local crontab user's email, so try mail (as the same user) and see if you have a bunch of messages from your crontab.
pgrep crond returning nothing sounds like the problem, but I'm not a sysadmin. Maybe you want to flag this and ask for moderator to move to https://serverfault.com/
I hope this helps.
I think it is related to the user permissions. Try putting in default crontab hourly,weekly files, if it works there then your cron is good. Also, check /var/log/messages for any cron entry. View /etc/crontab for detailed configuration.

Resources