Hi friends i have a script "backup.sh" which is stored in "/var/lib/pgsql" directory.
I want it to run as a cron so that it executes every time the system starts.
I tried the follwing method
I logged in as the root user and typed "crontab -e"
The file was completly blank so i put the following line @ the beggining of the file
"@reboot /var/lib/pgsql/backup.sh"
It said "crontab: installing new crontab"
But the cron did not run when i restarted the system(the script "backup.sh" mails after the task is comleted to an email address)
So i typed "vi crontab" which resides in the "etc"directory the file was something like this:
------------------------------------------------------------------------------------------------------------
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
------------------------------------------------------------------------------------------------------------
I added the follwing line @ the end of the file
"@reboot /var/lib/pgsql/backup.sh"
So it looked like this
------------------------------------------------------------------------------------------------------------
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
@reboot /var/lib/pgsql/backup.sh
------------------------------------------------------------------------------------------------------------
Even this method failed.
Do i have to change the it to "@reboot bash /var/lib/pgsql/backup.sh"
where u have to specify the command to enter "bash" in this case or enter "root" before the script path
Can anybody pls help me in achieving the follwing task I would be very greatful.