LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   auto running a command (https://www.linuxquestions.org/questions/linux-newbie-8/auto-running-a-command-452364/)

mrgreaper 06-07-2006 06:29 AM

auto running a command
 
hi just a quick question
i need to run a command namely
Code:

perl hlstats-awards.pl
once a day automaticly preferably in the background but i have no idea how?

im using suse 10 if that helps

slackie1000 06-07-2006 06:36 AM

hi there,
Code:

man crontab
or put an executable under
Code:

/etc/cron.daily
regards,
slackie1000

mrgreaper 06-07-2006 07:08 AM

Quote:

Originally Posted by slackie1000
hi there,
Code:

man crontab
or put an executable under
Code:

/etc/cron.daily
regards,
slackie1000

not sure i understand first comand takes me to a manual for something called crontab the second seems more promising but its a pl file i need ran not a exe (or sh forget what executables are called in linux)

slackie1000 06-07-2006 07:11 AM

hi there,
can you write perl but can't read a man page?
Code:

echo "perl hlstats-awards.pl" > /etc/cron.daily/nothing.sh
chmod 755 /etc/cron.daily/nothing.sh

maybe you need to give the complete PATH of hlstats-awards.pl
regards,
slackie1000

mrgreaper 06-07-2006 07:49 AM

Quote:

Originally Posted by slackie1000
hi there,
can you write perl but can't read a man page?
Code:

echo "perl hlstats-awards.pl" > /etc/cron.daily/nothing.sh
chmod 755 /etc/cron.daily/nothing.sh

maybe you need to give the complete PATH of hlstats-awards.pl
regards,
slackie1000

im unable to write perl (no experience) i have to admit this perl file is part of a counter-strike server stat page http:\\grimreaper.uk.to\tr\hlstats.php it generates the dialy awards (though its been edited to include the last seven days instead(the servers not run every day)

thank you for the help will let you know 2morro if it works lol (wont know till then i guess)

edit *updated the url gave the wrong one*

mrgreaper 06-09-2006 09:55 AM

nope it didnt apear to work any ideas?

slackie1000 06-09-2006 10:01 AM

hi there,
how did you proceed? did you give the complete path of your perl script in the script? could be that you have some permission issue? trying to write something in some directory that you can't?
regards,
slackie1000

mrgreaper 06-10-2006 07:28 AM

Quote:

Originally Posted by slackie1000
hi there,
how did you proceed? did you give the complete path of your perl script in the script? could be that you have some permission issue? trying to write something in some directory that you can't?
regards,
slackie1000


followed your instructions on permissions

gave it an absolue pathe

the pl file it opens is 777 in permission

and it writes to a sql file (with root access inside the pl file)

the sh file we created has the whole path in it

slackie1000 06-10-2006 08:04 AM

hi there,
so, the file is under /etc/cron.daily/ and every permission issue is ok.
what happens if you run the script from inside /etc/cron.daily ?
Code:

cd /etc/cron.daily/
./script_containing_your_perl_call

it runs fine?
regards,
slackie1000

ghatamos 06-10-2006 08:51 AM

should be, unless it have some requirement that it needs to be run on a specific location.

ethics 06-10-2006 09:56 AM

Ignoring the schedule for now, does the command do what it is supposed to when put into a shell?

mrgreaper 06-11-2006 10:05 AM

/serv/www/htdocs/tr/perl/perl does not exist
i have changed it to perl /srv/www/htdocs/tr/perl/hlstats-awards.pl
but when i execute the command i get i get a load of errors

so i changed it to

#!/bin/sh

cd /srv/www/htdocs/tr/perl/
perl hlstats.awards.pl

that seems to work fine when issued from the command line but no idea how it will fair dially well let you guys know in a couple of days

slackie1000 06-11-2006 10:55 AM

hi there,
if this
Code:

#!/bin/sh
cd /srv/www/htdocs/tr/perl/
perl hlstats.awards.pl

code works fine from cli you can save it under a name - ex. stats.sh - and put the file in /etc/cron.daily/ .
regards,
slackie1000


All times are GMT -5. The time now is 09:29 PM.