To setup cron job from ssh, firstly we need a ssh client like putty for windows.
Then,
Open the ssh client.
Connect to the host using the ssh credentials.
Type crontab -e command to view the cron file. There we can see the scripts to setup the cronjob something like this:
GNU nano 2.2.6 File: /tmp/crontab.nUqtfZ/crontab Modified
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
We can see the lines are commented. No cron script has been setup here.
To add cron script, we can write it at end of the file.
After adding cron script,
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * php -f /var/www/organic.draftserver.com/public_html/croneway.php >> /$
MAILTO=prasana.shrestha@ebpearls.com
This cron script is scheduled to run every time cron is runned.
Mailto function will send email.
Then,
Open the ssh client.
Connect to the host using the ssh credentials.
Type crontab -e command to view the cron file. There we can see the scripts to setup the cronjob something like this:
GNU nano 2.2.6 File: /tmp/crontab.nUqtfZ/crontab Modified
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
We can see the lines are commented. No cron script has been setup here.
To add cron script, we can write it at end of the file.
After adding cron script,
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * php -f /var/www/organic.draftserver.com/public_html/croneway.php >> /$
MAILTO=prasana.shrestha@ebpearls.com
This cron script is scheduled to run every time cron is runned.
Mailto function will send email.
Comments
Post a Comment