PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

setting up linux cronjobs

Go down

setting up linux cronjobs Empty setting up linux cronjobs

Post by jamied_uk 4th May 2013, 21:44




Part 2


in command line (shell terminal)



Type The Following

Code:
crontab -e

crontab.guru/every-1-hour

Code:
@hourly -f /home/jay/Documents/Scripts/Gold/gold.sh >/dev/null 2>&1

To find your working directory

Code:
pwd



edit and exit and save!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Running php scripts using crontab examples for locallay executable php files

Code:
*/5 * * * * php -f /var/www/html/cj/email1.php >/dev/null 2>&1


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



now includes line make sure it is like this example

include("/host/web_server/www/php_includes/file_to_include.php");


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To run a php script from a cli
Now inside the php file you can add this to the top of the line
#!/usr/bin/php5



~~~~~~~~~~~~~~~
Remote cronjob examples

*/5 * * * * php -f http://www.yourserver.com/cj/email1.php >/dev/null 2>&1


The following has code at the end to stop any email on cronjobs

>/dev/null 2>&1


Last edited by jamied_uk on 5th October 2018, 10:53; edited 1 time in total
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

setting up linux cronjobs Empty Re: setting up linux cronjobs

Post by jamied_uk 5th October 2018, 10:23

Every hour during working hours

Code:
0 9-17 * * *
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

setting up linux cronjobs Empty Re: setting up linux cronjobs

Post by jamied_uk 5th October 2018, 10:31

My Working Example

Code:
# Gold Prices every day in working hours
0 9-17 * * * /home/jay/Documents/Scripts/Gold/gold.sh >/dev/null 2>&1
# Web Site Mail Cronjoobs
*/5 * * * * php -f /var/www/html/cj/email1.php >/dev/null 2>&1
*/5 * * * * php -f /var/www/html/cj/email2.php >/dev/null 2>&1
*/5 * * * * php -f /var/www/html/cj/email3.php >/dev/null 2>&1
*/5 * * * * php -f /var/www/html/cj/email4.php >/dev/null 2>&1
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

setting up linux cronjobs Empty Re: setting up linux cronjobs

Post by jamied_uk 5th October 2018, 11:48

If fails to run you can add paths


set path if script fails


Code:
PATH=/opt/someApp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

setting up linux cronjobs Empty Re: setting up linux cronjobs

Post by jamied_uk 5th October 2018, 22:21

jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

setting up linux cronjobs Empty Re: setting up linux cronjobs

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum