I have never entered mailwizz cron jobs to plesk so I am very confused.
I need to add following cronjobs:
* * * * * /usr/bin/php -q /var/www/vhosts/mangud.pw/httpdocs/kampaania/latest/apps/console/console.php send-campaigns >/dev/null 2>&1
Here you can see were the cron job has to be entered:
I have tried different ways but till now it runs with errors.
i have resolved the problem by using "Run a PHP script" and i have changed the command
from : ** * * * * /usr/bin/php -q /var/www/vhosts/wizomail.xyz/httpdocs/apps/console/console.php send-campaigns >/dev/null 2>&1*
To: /var/www/vhosts/wizomail.xyz/httpdocs/apps/console/console.php in script path
and send-campaigns as arguments
i m not a pro but i get result :)
enter image description here
Related
I made a script in TypeScript that download data from some api and store inside a mongo DB.
If i run yarn start from the app folder it works well.
I would like to put this command in a cron job that will be executed every 5 minutes.
I try it with some sintax in crontab but ti doesn't work.
I try to put the call in a run.sh script but it doesn't work too.
*/5 * * * * cd /opt/app-folder/src/ && /home/username/.nvm/versions/node/v16.15.1/bin/ts-node main.ts
*/5 * * * * cd /opt/app-folder && /usr/bin/yarn start > /home/username/app-name-out.txt
*/5 * * * * /home/username/run.sh > /home/username/app-name-out.txt
*/5 * * * * /home/username/.nvm/versions/node/v16.15.1/bin/ts-node /opt/app-folder/src/main.ts > /home/username/app-name-out.txt
*/5 * * * * cd /opt/app-folder/src/ && /home/username/.nvm/versions/node/v16.15.1/bin/ts-node main.ts > /home/username/app-name-out.txt
Can someone help me to execute the main.ts every 5 minutes?
Thanks
I get rid of this problem.
There was 2 problems, the first related to the output redirection.
I fixed by redirect stdout in a file and stderr in another one.
The second was related the the $PATH of crontab: it was /usr/bin:/bin.
To fix it I log into my user where script works and I print my $PATH with echo $PATH.
I copied the value and I set it before the crontab line in crontab file.
This is what it looks like:
# Set the same path of user username to have the correct path in script
PATH=/home/username/.nvm/versions/node/v16.15.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
# Execute oracle every 5 minutes
*/5 * * * * /bin/sh /home/username/run.sh >> /home/username/app-name-info.txt 2>> /home/username/app-name-error.txt
Now it works.
I'm trying to run a cronjob to start and stop a server under a non-sudo user. I've tried asking others and doing what I saw from looking on google before asking here, but I'm still stuck.
Here's what's in my crontab for the server user:
* * * * * /home/server/startup/stop.sh
* * * * * /home/server/startup/start.sh
Here is what is in my stop.sh script:
#! /bin/sh
screen -r server -X quit
Everything runs normally if I run it using sh, and I only encounter a problem when using cron.
From what I see there could be 2 possible problems:
If the lines you are running in crontab are (and only those):
home/server/startup/stop.sh
home/server/startup/start.sh
then you are missing the time part of the line. If you want to run your program only once on boot you can run:
#reboot home/server/startup/start.sh
You are not giving the full path to your program (possibly you are just missing a / in the begging). Try running
* * * * * /home/server/startup/start.sh
or
#reboot /home/server/startup/start.sh
If these don't work I recommend you try the following to troubleshoot the issue:
Run the command using sh in the cron:
* * * * * /bin/sh /home/server/startup/start.sh
Try redirecting the stdout and stderr of your command to a file and see if any errors occur
I've got such situation:
I want to schedule a job with crontab on a linux server. I'm not super-user, so I'm editing (with crontab -l, editor vim) only my crontab file. For testing, I put there:
* * * * * echo asdf
And the job is not running. Is the restart of the server needed? Or maybe some administrator move?
May be it is, cron jobs will run in their own shell. So you can't expect to see asdf on your console.
What you should try is
* * * * * echo asdf > somefile_in_your_home_directory_with_complete_path.log
Next check the file by doing a tail:
tail -f somefile_in_your_home_directory_with_complete_path.log
And if it's not, check if the cron daemon itself is running or is down:
# pgrep crond
OR
# service crond status
If you want to echo something on your shell you could use wall:
* * * * * wall <<< "Hello from cron"
* * * * * echo "Hello from cron" | wall
These two lines basically do the same but the first one might not work on older shell, just choose your favorite.
Anyway, be aware that wall will send your message to every user currently connected.
For me * * * * * /bin/echo text > file is not working...I don't know why, previleges and everything is set.
(This command is running normaly when I execute it as the particular
root user, just to clarify this.)
This can be solved by injecting the path PATH=$PATH:/bin in my example.
Instead * * * * * echo text > file is working fine, probably path issue.
Hope I helped
I have a very simple script that works from the command line.
#!/bin/bash
reboot
When I put a call to execute the script into root users crontab -e using the following format it does not run. It does run the first two commands, just that last one is giving me grief. I have no MTA installed as I do not need it.
*/10 * * * * service jwtpay restart
0 3 * * * bash /root/backup/mongo.backup.s3.sh kickass /root/backup >/dev/null 2>&1
0 */3 * * * bash /root/reboot.sh >/dev/null 2>&1
What am I missing?
Maybe the script is not executable... Since you use root's crontab why call the binary via a script and not the binary itself? Use the full path to the binary. It may vary on your system. Find out where it is with which reboot.
0 */3 * * * /sbin/reboot
Don't forget to restart the cron daemon, after changeing the crontab.
I know this may have been answered earlier in various posts, but I've not been able to make this run myself.
I have a bash script (service.sh) that I would like to run every minute. It needs an argument to be passed (start in this case).
Using another script (test.sh) I am scheduling the cron expression for the above script:
echo "* * * * * /opt/service.sh start" > /opt/cronForSecops
crontab /opt/cronForSecops
I can see by using crontab -l that this is being set correctly as:
* * * * * /opt/service.sh start
However, the service.sh does not run, and I see no logs/files being created (which the service.sh file is supposed to do, when I run it normally).
Can anybody please guide me on where I am going wrong?
I was having this same issue where I using the following crontab:
0 23 * * * sudo -u myname /home/myname/bin/buildme.sh -f >> /home/myname/log.txt
And inside the bash script I was using this to get the -f option:
while getopts ":f" opt; do
case $opt in
f)
force_full=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
So I noticed that the option wasn't being honored when I ran this through cron for some reason. Well, adding /bin/bash to the cronjob fixed it right up. The new crontab is:
0 23 * * * sudo -u myname /bin/bash /home/myname/bin/buildme.sh -f >> /home/myname/log.txt
Hope it helps!
Try creating a simple wrapper script called /opt/start-service.sh with this content:
#!/bin/sh
/opt/service.sh start
and make sure it's executable then use
* * * * * /opt/start-service.sh
as the crontab entry