• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Crontab

A

AvidCat

Guest
I need to schedule a cron job to execute a file on my server once a day. I understand what I need to enter into all the fields except the Command field. What language do I need to type into this field to execute a file on my server? Do I need to just type the location of the file?
 
Not sure if it is going to be an executable file. I run a script on our site. I want to start using an option that sends out automated emails. I am waiting for a reply from the script owners as to how to create this file, save it and what type of file to save it as.

Here is the instructions for the file if it helps.
__________________________________________________________

Sending Expiry Emails to Link Owners Who's Links is About to Expire

You will need to execute exp_emails.cgi on a daily basis to be able to send out emails to premium link owner's who's premium links are about to expire. You will normally want to use the Unix CRON program to accomplish this. Many hosting companies provide options to use the Unix CRON program. The Unix CRON program is a scheduler which will execute files on a scheduled basis. (Once a day or any time interval you specify)

Note that you cannot just execute exp_emails.cgi with the Unix CRON program. The reason for this is that exp_emails.cgi needs to be executed in the working directory where it resides.

To make the directory in which exp_emails.cgi resides in, the working directory, you can create a Unix shell script, (Almost like a dos batch (.bat) file) that executes generate.cgi

The shell script should look something like this:

cd /home/yourdomain/www/cgi-bin/admin # Change to exp_emails.cgi working dir
perl exp_emails.cgi # Execute exp_emails.cgi

Note that a shell script is a normal text file that you create and upload to your web host or server. Also note that you will most likely need to assign executable permissions to it (permissions of 755) - Click here to find out how to set file permissions.
___________________________________________________________

I don't work with these types of files so I am trying to learn it step by step.
 
I guess, I don't have any expierence with these types of files.

Mainly I don't know what to save the file as. I know I can use notepad to create and save it. But do I just save it as a .txt file.

I am also not sure since I don't work with these types of files if I just copy the sample and place my direct server link in the first spot.

i.e. Do I need to change the last part of the code

"# Change to exp_emails.cgi working dir
perl exp_emails.cgi # Execute exp_emails.cgi"

When I saw the word Change in there I am thinking, do I need to change something or is that the code langugage that changes exp_emails.cgi to the working directory.

I think you might see it and think, it really is simple to do. For me it looks French :)
 
You need to make a file called email.sh
or something that means something to you.

In it put

#/bin/bash
cd /home/yourdomain/www/cgi-bin/admin # Change to exp_emails.cgi working dir
perl exp_emails.cgi # Execute exp_emails.cgi

Yout need to change the path in the cd command to the correct path to your file.

Most likely something like this

/usr/local/www/vhosts/domainname.com/httpdocs/emailscript/email.sh
 
Thanks, if I create a file with the extension of .sh, what command would I use from the cronjob that I create. Not sure what it should look like.
 
Not really sure, but try using the full path to the file.
That should do the job.
 
Linux doesn't care about the extension. Just make sure the file is executable by the user it needs to run as. Everything after a '#' is just a comment about what the code does (so can be omitted), except for #! on the first line which says what interpreter to use. You could create a file that contains this:

Code:
#!/bin/sh
cd /home/yourdomain/www/cgi-bin/admin
perl exp_emails.cgi

And of course you'll need to adapt the path to the real path of the exp_emails.cgi file.
 
That *is* making it executable. But maybe 755 is more permissions than is needed. If the crontab is running as the user and the file is owned by the user 700 should be enough.
 
Very cool, thanks everyone. It is starting to make more sense. I will start testing with it today and let you know how it goes.
 
Back
Top