• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Question Need help with cron tab

cipcip

Basic Pleskian
Hi guys,

I need help setting up a crontab on my plesk server. It seems that I cannot get it to work :( ...

I am using:
*/5 * * * * pgrep -f main.py || nohup python3 cd /var/www/vhosts/criago.com/httpdocs/pie/main.py >> /var/www/vhosts/criago.com/httpdocs/pie/freakin.log

So basically, I want it to run / check every 5 minutes to see if my script is running. If is not running, start it, if it is running skip.

The log files is not getting created and the cron never starts. I am testing with:
ps ax | grep main.py

What I get ?

27781 ? Ss 0:00 /bin/sh -c pgrep -f main.py | pgrep python3 || nohup python3 /var/www/vhosts/criago.com/httpdocs/pie/main.py > test.out
27785 ? S 0:00 python3 /var/www/vhosts/criago.com/httpdocs/pie/main.py
29506 pts/0 S+ 0:00 grep --color=auto main.py

One other thing, I do not understand why I have multiple entries ? How can I delete the extra ones ? Because if I open the file under: /var/spool/cron/crontabs/root , I only have the one that I am using there, not the old ones anymore.

I also tried to use: sudo service cron reload - but it is not starting or the old ones are not being removed.

Thank you,
Cristian.
 
I couldn't get cron to work so I did it using a service.

I have created the file testing.service in /etc/systemd/service/ with:

[Unit]
Description=my criago service crawler
After=multi-user.target

[Service]
Type=idle
User=root
ExecStart=/usr/bin/python3 /var/www/vhosts/criago.com/httpdocs/pie/main.py
Restart=always
TimeoutStartSec=10
RestartSec=10

[Install]
WantedBy=multi-user.target

Then ran the following commands in Putty:

sudo systemctl daemon-reload

sudo systemctl enable testing.service

sudo systemctl start testing

Seems to do the trick. But this is really the correct approach ?

Thank you,
Cristian
 
Back
Top