Getting cron job to execute script on OSX 10.10 (Yosemite) XAMPP - cron

Been messing around with XAMPP Cron Jobs for awhile and can't seem to get these to work right. This is being run on my personal computer for Mac OSX Yosemite. Using the terminal to make this work. The script is a PHP file. I put the default application to open up in a browser. It runs the cron job but it opens it up as if it is a text file and not as if it is a php script.
I did test this individually script separate from the cron and it works fine. Just for testing purposes I have it just writing to basic txt file. The paths are the default that pretty much comes with XAMPP.
Example of cron job in terminal
1 * * * * /usr/bin/open /Applications/XAMPP/xamppfiles/htdocs/rest of my path/write.php
The cron job does pull up the script in the default browser but is read like a text file.
So in the URL bar it starts off with file:// and than the cron job command path listed in the example.
Two questions:
1 Is there a way to make this execute the same way if I visited the webpage?
2 Is there a way to make this run in the background?
Thanks for any input.

Related

Run Google Assistant SDK on boot (Raspbian)

I am currently trying to get a cron job working, so that the google assistant starts automatically after boot. For that I created this cron job which executes on reboot.
SHELL=/bin/sh
PATH=/usr/bin:/bin:/home/pi/Desktop:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#Reboot lxterminal -t "Google Assistant" -e /bin/bash /home/pi/Desktop/init.sh
lxterminal will open a window with google assistant running within.
Here is my full cron job:
#!/bin/bash
SHELL=/bin/sh
PATH=/usr/bin:/bin:/home/pi/Desktop:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
source /home/pi/env/bin/activate
python3 /home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/grpc/pushtotalk.py
I already tried answers from similar problems and even specified the path variable for cron, but it still won't work for me. The script isn't the fault, when I execute it manually it runs fine.
The problem wasn't with cron, though I settled for using a systemd service instead.
What I didn't know was, that Lxterminal needed a initalized screen to work and due to the script running on boot it wasn't.
This is an easy fix. Either add an delay of 30 Seconds or other values, depending on your system, to the beginning of your script or simulate the display beeing initalized already with export DISPLAY=:1

Using Gnome-Schedule to run shell script that opens Chromium browser

I have a Raspberry Pi running Raspbian 8.0. I have a shell script that triggers a Chromium Browser to open and go to a specified URL that changes every day. The shell script works when executed from the terminal. How would I get this to work through Gnome Schedule's GUI? I would like this to trigger everyday at a specified time. I've tried setting the command to /home/pi/test.sh, sh /home/pi/test.sh. I read something about needing to specify the display output since I'm running Gnome Schedule from root which isn't the current user logged in. So for that I tried export DISPLAY=:0 && /home/pi/test.sh. Is this going to be possible?
If you put
export DISPLAY=:0.0 at the top of your script rather than export DISPLAY=:0, this should work.

What the best workaround for run CPanel cron scripts today?

After CPanel updated in 2013 any cron scripts work in jailedshell regardless account have no shell or jailedshell ... All my scripts working fine when its started as usual under Apache, but I have problem to start the same scripts under cron.

install script to run then reboot and continue

I have a script that is a pre installation script for a specific piece of software. the script takes care of a lot of the pre-requisites of the installation as well as kernel configuration.
What I am trying to do is create a set of scripts that automates the entire installation of this software and what I would like to know is if there is a way to have a script reboot the box and then ONE TIME kick off the second script that will execute the post reboot commands automatically to complete the installation.
I have several boxes I need to run this on (in excess of 40-50) and would really appreciate a way to do such a task where i can run the first script and have it take care of the reboot and completion of install.
Any ideas?
A solution is to add the script path in /etc/rc.local, that way, the script will be ran #reboot

running cronjobs from plesk

I have Plesk (or more accurately Parallels Small Business Panel) installed on my linux server. However, my knowledge of linux is pretty limited. I am trying to set up a cronjob that will run a php file.
I have found the scheduled tasks area in plesk and filled in the details for when i want the script to run e.g. 30 9 * * *. However I seem to be having difficulty writing the correct command. I am using:
usr/bin/php -q /var/www/vhosts/mywebsite.co.uk/httpdocs/admin/file_to_run.php
I have checked that the location of php is correct using:
whereis php
I have also checked that the path to the file is correct using:
find / -name 'file_to_run.php'
However the php page is not doing it's job at the specified time. Can anyone help me get to the bottom of this?
Two possibilities
1) Check if the script has an error by doing a dry run on the command line.
Because you will not see this error when the cron user runs the command.
2) Perhaps you want the output to go to a specific file?
You can redirect it as such :
usr/bin/php -q /var/www/vhosts/mywebsite.co.uk/httpdocs/admin/file_to_run.php > /your/destination/the_output
Unless your php script handles everything it needs on the inside, that is.

Resources