Im very new to command line so please forgive my ignorance. I can succesfully execute my script using putty by navigating to the relevant direcotry and typing
bash app_auth.sh
I'm now trying to set this scipt to run using cPanel cron job. I have tried the following but it doesnt work:
* * * * * /public_html/app/cron_jobs/app_auth.sh
Any help would be appreciated..
Though this thread is old but I found it unanswered hence replying.
Make sure that you have assigned execute permissions to your app_auth.sh file. Also, try setting the following cron:
* * * * * /public_html/app/cron_jobs/app_auth.sh > /home/YOUR_USER/cron.log 2>&1
Just for the record, I came across the same problem.
I found this webpage, which led me to do this:
/bin/sh /public_html/app/cron_jobs/app_auth.sh
And it worked fine!
Related
I have configured the modern authentication for O365 using App::wsgetmail module for RT, everything works fine when I run the the wsgetmail --config=config1.json via terminal it can access the email's inbox and create the ticket in RT and mark the email as read but when I am trying to use the crontab to do the same work periodically getting no result.
the corntab works with other cornjobs that I have for other tasks and only it is not working with wsgetmail.
the crontab looks like this:
*/1 * * * * wsgetmail --config=/path_to_config_directory/config1.json
Note:
I am using RT4
The config1.json file is executable
I am using root user for configurations
There is no any error in the logs
Any idea about this issue that I am facing with?
I have finally resolved the issue and posting the answer here for others that may face with same issue.
The crontab and terminal are two different environments, the wsgetmail perl module command is recognizable for terminal but to make it recognizable for corntab we have to add the full path to the module (wsgetmail) in the crontab.
*/1 * * * * /usr/local/bin/wsgetmail --config=/path_to_config_directory/config1.json
or we can create a shell script and call the script in crontab.
in this case test.sh will looks like this:
#!/bin/bash
/usr/local/bin/wsgetmail --config=account01.json
/usr/local/bin/wsgetmail --config=account02.json
I have a pretty simple db back-up script that runs perfectly from shell.
php /home/db_backup/db_backup.php
When I attempt to add a Crontab, I get the vague 'Bad Command errors in crontab, can't install."
I've tried w/ php and full path to php.
which php
returns /usr/bin/php
* 1 * * * php /home/db_backup/db_backup.php
* 1 * * * /usr/bin/php /home/db_backup/db_backup.php
Both return the same error.
Centos 6.6. logged in as root. Editing crontab thusly
crontab -e
Spent too many hours trying to get this working. What am I missing?
I bet your problem is when editing the crontab file not with the commands itself.
Be sure to let a blank line at the end of file.
I mean the cursor must be in an empty line after the last entry.
i have this crontab,
* * * * * php /etc/raddb/overloaded.php
but it is not running fine, meaning it doesnt run every minute, but when i manually enter this into the terminal (php /etc/raddb/overloaded.php), the script works
thank you guys
PS: im using centos 32 bit. also im using the "crontab -e" to insert and save crontab, but it looks like that crontab is not running? i typed "crontab -e" and yet (* * * * * php /etc/raddb/overloaded.php) appears. where is the issue here? thanks
Crontab syntax is right. Please check if your cron daemon is running and you can check log, maybe it conatins some usefull info.
I think the most possible problem is that cron has its own environment settings. Try to run php with its full path, e.g.
/sbin/php
or w\e path you have
I maintained a database (MySQL), I would like back up some data to the database using a perl script. To save my trouble, I would like cron to do it for me, I inserted the following using crontab
*/5 * * * * blctrl /home/blctrl/code/perl/tt01.pl
However, cron never does its job, any suggestions to get it done? The Linux installed is Centos 5?
*/5 * * * * blctrl /home/blctrl/code/perl/tt01.pl
That looks like the syntax for /etc/crontab, the system-wide crontab file. The first 5 words indicate when to run the command, the 6th is the account under which to run it, and the rest of the line is the command to execute.
(The clue was that the command is under /home/blctrl, which would be the home directory for the account blctrl.)
The syntax for your own crontab, the one you feed to the crontab command, is different. You don't specify an account name, because it only runs under your own account.
Try this:
*/5 * * * * /home/blctrl/code/perl/tt01.pl
EDIT: Incidentally, the first thing I would have tried when encountering a problem like this would be to replace the command with something simple, perhaps touch /tmp/FOO. That would have told you whether the problem was with your Perl script or with your crontab.
I'm trying to execute a shell script from cron on Freebsd.
To test whether crontab is working at all, I wrote the line
* * * * * echo "Hello" > /home/myuser/logile
and it work fine.
But when trying to execute any script it doesn't do anything, not even an error. (In the script I tried to run is just the same echo command)
Below is the output of crontab -l:
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
HOME=/home/myuser
MAILTO=myuser
* * * * * /home/myuser/shellscript.sh > /home/myuser/logfile
Why is the script not getting executed, although crontab is obviously running?
Permission for all files are set to rwxr-xr-x.
* * * * * /bin/sh /home/myuser/shellscript.sh
or
* * * * * /bin/bash /home/myuser/shellscript.sh
worked for me in Macosx 10.6 as rootuser
Have you checked that the command line has a linefeed/CR at the end of the line? I struggled for hours trying to find a reason for non-executing php script on cron when I simply hadn't pressed enter at the end of the line when I edited the cron jobs with crontab -e :-)
Have you checked /var/log/cron for clues?
Have you tried
* * * * * /bin/sh /home/myuser/shellscript.sh > /home/myuser/logfile
cron sends any errors via email to owner of the crontab file (often "root" so you might check that account's email). To have any errors mailed to "crontabOnFreebsd" put:
MAILTO=crontabOnFreebsd
in your crontab (near the top).
For more info issue this command:
man 5 crontab
If you are getting an error, then your logfile might not capture it, try this:
* * * * * /home/myuser/shellscript.sh > /home/myuser/logfile 2> /home/myuser/errorfile
Its been a while since I did any cron stuff; but things that always used to get me:
Environment variables not been set: generally I found it necessary to set up full paths (even to things like 'cat') to all commands [or at least set ENV variables within the script itself].
Ensure the user who owns the script etc is really the user which is running the script: this might not be the same user when you test from the interactive shell. Same goes for the directories/files that the script might write to.
Also: check the email for the root user - you might find that the errors have been diverted to the inbox, which may help you troubleshoot this further.