Magento 2 – Help on how to run a script on db via cron

I was looking for a solution that would disable products with no images so the catalogue is not randomised by ones that have our image place over. Looks messy.

I found this on stackoverflow, which is a script to run in the database but at the moment it’ll mean i’ll have to manually run this every day when my product feeds are imported (via cron) into the shop

update catalog_product_entity_int m left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id =  m.attribute_id set value = 2 where   a.attribute_code = 'status'   and m.entity_id in     (   select m.entity_id   from catalog_product_entity m   left join catalog_product_entity_media_gallery_value_to_entity a   on a.entity_id = m.entity_id   where a.value_id is null ) 

;

How would i go about getting this run on the database automatically by cron?

Error: Cron has not run recently. But it did!

Cron has not run recently, but it did I have a site (hosted on Acquia) which always return an error about cron not running on the Status report page, but it actually runs regularly and it does all the task attached to it.

Cron is running externally (through Acquia panel) and Automated Cron is disabled. The error appears regardless of the method I use to run cron (Drush, Admin UI, Externally).

I couldn’t find any issue trying to debug this, it seems just a “false positive”.

Any suggestion on how I could get rid of the error?

Thanks

Magento 2: How can I fix my cron issue?

I’ve installed Magento 2.3 on my server. Currently I am trying to activate cron, but unfortunately I always get the same notice when I try to install and run it.

Error during saving of crontab: sh: line 6: crontab: command not found 

I’ve already googled some answers, but it didn’t allow me to fix the problem.

I would be really grateful if some of you could help me.

Criar arquivo cron para disparos de e-mails sem acesso ao CPanel Linux

O site de um cliente está em um servidor, do qual não tenho acesso. Eles me passaram apenas os dados do FTP e o BD, porém preciso criar uma tarefa cron onde naquele determinado dia do vencimento (o dia depende do dia em que foi feito o cadastro e não é um dia fixo do mês), fosse disparado um e-mail para o usuário. Tem algum meio de criar essa tafefa cron sem usar o CPanel?

A ideia inicial é criar um arquivo em php, por ex.: enviar-cobranca.php onde eu puxasse a data de vencimento e através de uma tarefa do servidor, o disparo fosse efetuado automaticamente, sem manuseio manual. Algo como:

$  sql = mysqli_query($  conexao,"SELECT IdUSuario, DataVencimento FROM pagamentos;");  while($  listar = mysqli_fetch_object($  sql)) {    if($  listar->DataVencimento == date('Y-m-d'))    {        // Faria o disparo usando o PHPMailer    } } 

Só falta criar essa tarefa cron para fazer esse disparo.

cron job for downloading multiple files with wget

I want to download multiple files, so I decided to create 4 text files that are handled with a script.

toDownload.txt | this file will hold a list of links to download. inQueue.txt    | the files currently downloading will move here and if failed we can continue later using wget -c flag. downloaded.txt | this file will hold file links that have finished downloading. failed.txt     | this file will hold links that failed to start downloading for example if the URL returns 404. 

how can I move the first x number of links from a file and move it to another file?

Sending email to gmail from cron

Looking for help sending email to a gmail address from my cron. At the top of crontab

MAILTO="obfuscated@gmail.com" 

But no mail comes. Checking /var/log/maillog, I see

Dec 17 22:46:36 myserver postfix/pickup[30426]: CC21261C6E: uid=501 from=<root> Dec 17 22:46:36 myserver postfix/cleanup[30486]: CC21261C6E: message-id=<20181217224636.CC21261C6E@myserver.novalocal> Dec 17 22:46:36 myserver postfix/qmgr[11071]: CC21261C6E: from=<root@myserver.novalocal>, size=5920, nrcpt=1 (queue active) Dec 17 22:46:37 myserver postfix/smtp[30488]: connect to gmail-smtp-in.l.google.com[2607:f8b0:400e:c03::1b]:25: Network is unreachable Dec 17 22:46:37 myserver postfix/smtp[30488]: CC21261C6E: enabling PIX workarounds: disable_esmtp delay_dotcrlf for gmail-smtp-in.l.google.com[74.125.197.26]:25 Dec 17 22:46:37 myserver postfix/smtp[30488]: CC21261C6E: to=<obfuscated@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.197.26]:25, delay=221, delays=220/0.02/0.34/0.39, dsn=2.0.0, status=sent (250 2.0.0 OK 1545086797 31si11773098plk.310 - gsmtp) Dec 17 22:46:37 myserver postfix/qmgr[11071]: CC21261C6E: removed 

So, clearly, the IPv6 version is blocked, but the fallback gets a success message, yet no mail ever arrives. Same messages if I try using the command-line mail command. However, I can use the command-line mail program to successfully send mail to my company email address.

mail -s "test1" obfuscated@mycompany.com test1 EOT 

The telnet trick seems to indicate I can access the gmail server:

$   telnet gmail-smtp-in.l.google.com 25 Trying 108.177.98.26... Connected to gmail-smtp-in.l.google.com. Escape character is '^]'. 220 ************************************************* ^]  telnet> quit Connection closed. 

My IP tables look like this

Chain INPUT (policy ACCEPT) target     prot opt source               destination          ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED  ACCEPT     icmp --  anywhere             anywhere             ACCEPT     all  --  anywhere             anywhere             ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh  ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http  REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited   Chain FORWARD (policy ACCEPT) target     prot opt source               destination          REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited   Chain OUTPUT (policy ACCEPT) target     prot opt source               destination          

Any help on this will be greatly appreciated.

Editing cron timestamp in wp_option table

Let’s say I have a multisite with ~1000 blogs. One of the plugins triggers an action once a day using wp_cron. The issue is that this triggers on all sites at around the same time, slowing down the server. I would like to spread those actions out through the day.

As the timestamp of the next trigger is stored for each blog in the table wp_N_option, I was thinking of editing it through get_option and update_option.

Could there be any unforeseen side effects to this, or is it safe ? Is there information stored about wp_cron outside of this option table ?