setting up linux cronjobs
Page 1 of 1
setting up linux cronjobs
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
Re: setting up linux cronjobs
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
Re: setting up linux cronjobs
If fails to run you can add paths
set path if script fails
set path if script fails
- Code:
PATH=/opt/someApp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Re: setting up linux cronjobs
Gold Prices Example Cronjob for working hours
https://jnet.forumotion.com/t1633-live-gold-price-for-linux-bash-script-example#2513
https://jnet.forumotion.com/t1633-live-gold-price-for-linux-bash-script-example#2513
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|