LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   regarding crond (https://www.linuxquestions.org/questions/linux-newbie-8/regarding-crond-793933/)

m4manoze 03-08-2010 05:30 AM

regarding crond
 
Dear Experts,

I am using "CentOS release 5.3", i have certain python script (expire.py) to run daily, i put that file (expire.py) in /etc/cron.daily/expire.py

To my knowledge it should automatically run the python script expire.py daily, but it is not runing since users are not getting expiry emails.

But if i manually run the expire.py by:
#python expire.py

it works!!!!

I want expire.py runs daily so that user gets expiring information daily. Need help, any help will be appreciated.

Regards,
Manoj

vishesh 03-08-2010 05:38 AM

I think cron.daily job run every day 4.2 am ensure that system is up at that time and also ensure proper permissin on python script file.

Thanks

giammy 03-08-2010 07:57 AM

Hi,

Rember that running from cron you do not have the same environment
as user: for example you do not have the PATH (and commands should use
full path)

There're various thread on this problem in this site!

bye
giammy

m4manoze 03-09-2010 12:11 AM

Quote:

Originally Posted by giammy (Post 3890190)
Hi,

Rember that running from cron you do not have the same environment
as user: for example you do not have the PATH (and commands should use
full path)

There're various thread on this problem in this site!

bye
giammy

Dear Giammy,

I have given full path inside the code. Regarding file permission i have set to #chmod 777 expire.py and to all associated file needed for expire.py to run.

Is there any script or anyother method through which we can test cron.daily runing or not?

Regards,
Manoj

linuxlover.chaitanya 03-09-2010 12:25 AM

If cron.daily is not working you can create crontab entry to run that script everyday at specified time. In addition if it does not run just that way you can explicitly call python to execute the script.

giammy 03-09-2010 02:37 AM

Quote:

Originally Posted by m4manoze (Post 3891063)
Dear Giammy,

I have given full path inside the code. Regarding file permission i have set to #chmod 777 expire.py and to all associated file needed for expire.py to run.

Is there any script or anyother method through which we can test cron.daily runing or not?

Regards,
Manoj

Hi,

you can create a script

Code:

#!/bin/bash
echo "i'm cron" > /TESTCRON

and put in cron.daily.
Then check if the file /TESTCRON has been created

bye
giammy

P.S: do you already looked at logs!

m4manoze 03-09-2010 05:34 AM

Quote:

Originally Posted by linuxlover.chaitanya (Post 3891074)
If cron.daily is not working you can create crontab entry to run that script everyday at specified time. In addition if it does not run just that way you can explicitly call python to execute the script.

Yes, I have call python script from bash as:

python file name : expire.py
bash script file name: expire.sh

In expire.sh,

[root@localhost cron.daily] vi expire.sh
----------------------------------------
#!/usr/bin/python
python /etc/cron.daily/expire.py

----------------------------------------

But it is not working. Regarding crontab I have no idea. Sorry!!!

Regards,
Manoj

giammy 03-09-2010 05:37 AM

Quote:

Originally Posted by m4manoze (Post 3891342)
Yes, I have call python script from bash as:

python file name : expire.py
bash script file name: expire.sh

In expire.sh,

[root@localhost cron.daily] vi expire.sh
----------------------------------------
#!/usr/bin/python
python /etc/cron.daily/expire.py

----------------------------------------

But it is not working. Regarding crontab I have no idea. Sorry!!!

Regards,
Manoj

this:
python /etc/cron.daily/expire.py
has not full path:
/usr/bin/python /etc/cron.daily/expire.py

bye

freelinuxtutorials 03-09-2010 09:52 AM

have you reloaded or restarted the crond service after adding it on /etc/cron.daily?
you can test your script if it will not generate errors by executing it directly /etc/cron.daily/filename


All times are GMT -5. The time now is 03:28 AM.