Jump to content

Cron job not running?


b0ardfac

Recommended Posts

I've set up a cron job to clear out some old temporary files periodically, but I can't tell if it's been running -- I have the email address setup but haven't received any messages, and files haven't been getting cleaned. Is there a way to test my cron job setup without running afoul of the twice-per-day limit?

 

User: b0ardfac

Server: tommy

 

Thanks!

 

Link to comment
Share on other sites

Here's his command:

0 0,12 * * * /usr/bin/env python3 /home/b0ardfac/cleanup.py

Since I know nothing about python, I'm not sure what it takes to execute a python script through cron, but with cgi/perl you only need the path:

0 0,12 * * * /home/b0ardfac/cleanup.py

And I believe you need to make sure file permissions are 755.

Edited by Byron
Link to comment
Share on other sites

I'll try that particular formation.

 

Should I be receiving emails from cron job attempts even if the execution fails? So far I have not received any emails about cron job execution.

 

My account was also recently autosuspended this past weekend for resource use, I'm not sure if that may be a factor?

Link to comment
Share on other sites

If your script isn't producing any output, you won't receive any emails:

 

 

You can have cron send an email every time it runs a command which produces output.

 

Just check to see if your script has cleaned your temporary files. I just set up a cron to run a cgi script and it works perfectly, but my script doesn't produce any output so i didn't get any cron emails.

Link to comment
Share on other sites

The first version I tried was using a script in my cgi-bin, and it was successfully executing from the browser. My first attempt at setting up the cron job had the command as "/home/b0ardfac/public_html/cgi-bin/cleanup.py" and that did not work.

 

My script always produces some output, which is why when I received no emails, I assumed the cron job was not running.

Link to comment
Share on other sites

Ok when I try running your script through SSH and using this path,

 

 

/usr/bin/python /home/b0ardfac/cleanup.py

 

I get an error:

 

 

root@tommy [~]# /usr/bin/python /home/b0ardfac/cleanup.py
  File "/home/b0ardfac/cleanup.py", line 24
    print(f'Cleaning up {path}')
                              ^
SyntaxError: invalid syntax
 
So it looks like you do need this path after all:
 
/usr/bin/python /home/b0ardfac/cleanup.py
 
but since i don't know python, I can't say that error is causing you any problems since you say you can execute it through your browser ok.
Link to comment
Share on other sites

Seems that works:

 

 

 
root@tommy [~]# /usr/bin/env python3.6 /home/b0ardfac/cleanup.py
Beginning cleanup.
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GWZ-31893827.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S4BE3X2WZ-31893941.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GWZ-31894403.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GWZ-31894579.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GWZ-31894614.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GWZ-31894858.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-VJ2K2PC2T4S2B2FNE3X2$Y2GW2Z-31895091.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GWZ-31895466.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-KC3T4S4BX2-31896640.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-VJ2K3C3T5S4B2F2E4X2$3Y2GW2Z-31896799.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S4BE3X2$3WZ-31898058.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GWZ-31898370.zip
Cleaning up /home/b0ardfac/ff4hack/seed_cache/FreeEnterprise-J2KC2T4S3BF2NE3X2$Y2GW2Z-FAIZ.zip
Cleanup done.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...