• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • The ImunifyAV extension is now deprecated and no longer available for installation.
    Existing ImunifyAV installations will continue operating for three months, and after that will automatically be replaced with the new Imunify extension. We recommend that you manually replace any existing ImunifyAV installations with Imunify at your earliest convenience.

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