Crontab bad minute - cron

I am trying to add multiple cron tasks in crontab.
Step 1
crontab -e
Step 2
* * * * * php /home/vagrant/project/artisan do:task 1 >> /dev/null 2>&1
1/3 * * * * php /home/vagrant/project/artisan do:task 2 >> /dev/null 2>&1
Step 3 - Save
crontab":1: bad minute
if I remove the 1/3 to become
3 * * * * php /home/vagrant/project/artisan do:task 2 >> /dev/null 2>&1
it saves fine but I need the offset.
Any help would be appreciated.

Figured it out.
I am using Laravel and i the task manager it parses
1/3 * * * *
perfectly fine but when using crontab I must use this format.
1-59/3 * * * *
Phew!!!
Schoolboy error!!! :-)

For others that might run into this issue, it can be either of the following problems:
The error "crontab":1: bad minute" actually mentions the line where the problem is: Here the error is with line # 1
Check if the hard disk is completely filled. The crontab cannot write the changes even in that case. Happens often !

Related

How to enter Mailwizz cron jobs in Plesk?

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

Running cron for nodejs and deleting files in temp

I'm trying to run nodejs /var/www/html/back/elastic/users.js g command every 10 minutes in cron but I don't seem to be able to
*/10 * * * * /usr/local/bin nodejs /var/www/html/back/elastic/users.js
I've added this to crontab -e but when I check syslog it doesn't show there.
Same for the following command I want to delete files in temp every day, it doesn't work either
30 2 * * * rm -rf /var/www/html/data/users/temp/*
What am I missing? Thanks for any help
Ubuntu Server 15.04
Try:
*/10 * * * * /usr/local/nodejs /var/www/html/back/elastic/users.js
and
30 2 * * * /bin/rm -rf /var/www/html/data/users/temp/*
You should try removing the space from the first crontab
*/10 * * * * /usr/local/bin/nodejs /var/www/html/back/elastic/users.js
the second command looks correct to me, is the path correct? Maybe a permission issue.
It should delete everything under /var/www/html/data/users/temp/ at 2:30am

Crontab - simple echo not running

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

Can't make crontab work

I am new to Linux and Ubuntu and I seldom have to use it. I am trying to make this PHP script to run every minute using cron, but firstly I wanted to make some tests.
I created an empty file at /var/www/html/ called test. I ran on terminal:
sudo crontab -e
And added this line:
0 * * * * rm /var/www/html/test
Then saved it and exited. It said "Installing new Crontab"
Nothing happened. Then I created a file bfile.sh that contained:
#!/bin/sh
rm /var/www/html/test
and added the following to crontab:
0 * * * * bash /var/www/html/bfile.sh
Still nothing happened.
What do I have to do to see anything happening from crontab? By the way I checked and the service is running
0 * * * * basically says "run this at 0th minute of every hour."
If you need cron to run your command every minute do * * * * *.
0 * * * * runs once every 1 hour. If you want to run every minute it should be */1 * * * *
You can also check the /var/log/cron file for any errors

crontab not running command

I've been trying to run a crontab command but it isn't running for some reason. The command is supposed to send push notifications.
My sudo crontab -e looks like this:
0 0 * * 0 /home/[user]/resetWeeklyLeaderboard
* * * * * /home/[user]/pushDelivery
I have a file called pushDelivery at the location above which contains the following:
/usr/bin/flock -n /home/[user]/PushChatServer/push/lockfile usr/bin/php /home/[user]/PushChatServer/push/push.php development
I have also made pushDelivery executable by doing chmod +x pushDelivery. This code works perfectly for my resetWeeklyLeaderboard file but won't call the pushDelivery file.
It works if I run
/home/[user]/pushDelivery
It works if I run
/usr/bin/flock -n /home/[user]/PushChatServer/push/lockfile usr/bin/php /home/[user]/PushChatServer/push/push.php development
However if in crontab I do
* * * * * /home/[user]/pushDelivery
or
* * * * * /usr/bin/flock -n /home/[user]/PushChatServer/push/lockfile usr/bin/php /home/[user]/PushChatServer/push/push.php development
it doesn't work. Please help me. Thank you!
UPDATE:
It still doesn't work but I've tried more stuff. I tried reversing the order in the crontab
* * * * * /home/[user]/pushDelivery
0 0 * * 0 /home/[user]/resetWeeklyLeaderboard
it doesn't work. I also tried making my resetWeeklyLeaderboard code run minutely
* * * * * /home/[user]/pushDelivery
* * * * * /home/[user]/resetWeeklyLeaderboard
and that works for my resetWeeklyLeaderboard code but not for my pushDelivery code. This implies to me that it is something in my pushDelivery code that is causing the issue. However I run /home/[user]/pushDelivery from command line and it works. What could be causing this problem?
i dont know why is is not running but same thing happens to me before at that time insted of doing
* * * * * /home/[user]/pushDelivery
try this
*/1 * * * * /home/[user]/pushDelivery
it worked for me in this way...(both the task run in every minute)
I fixed the issue. In my pushDelivery file I was supposed to write:
/usr/bin/flock -n /home/[user]/PushChatServer/push/lockfile /usr/bin/php /home/[user]/PushChatServer/push/push.php development
whereas I'd written:
/usr/bin/flock -n /home/[user]/PushChatServer/push/lockfile usr/bin/php /home/[user]/PushChatServer/push/push.php development
The "/" before the "usr/bin/php" makes all the difference. Somehow just that slash will allow it to work outside of crontab but will fail it when run inside crontab. I don't understand why but this is the correct solution.

Resources