Skip to main content
GrN.dk

Main navigation

  • Contact
  • Your Digital Project Manager
  • About Greg Nowak
  • Services
  • Portfolio
  • Container
    • Excel Freelancer
    • Kubuntu - tips and tricks
    • Linux Apache MySQL and PHP
    • News
    • Image Gallery
User account menu
  • Log in

Breadcrumb

  1. Home

Script

By Greg Nowak, 10 February, 2022

Delete Files and Folders Older Than X days

find /[FOLDER_NAME]/* -mtime +[OLDER_THAN_DAYS] -exec rm -rf {} \;

Example deletes all files and folders in tmp folder that are older than 180 days: find /tmp/* -mtime +180 -exec rm -rf {} \;

Tags

  • bash
  • Script
  • Linux
By Greg Nowak, 5 November, 2021

Cloudflare API

Handling DNS records from bash, including import of bind config zone file: https://github.com/tmiland/Cloudflare-BIND-Zone-File-Upload/blob/master…

Tags

  • Script
By Greg Nowak, 1 October, 2021

Check defined constants - PHP Code Snippet

<?php 

define('DISALLOW_FILE_EDIT', true);

echo "\n DISALLOW_FILE_EDIT is: " . constant('DISALLOW_FILE_EDIT') . "\n";

//$constants = get_defined_constants();
//var_dump($constants); // pretty large list
?>

Key words: define defined constant constants

Tags

  • Script
  • php
  • Linux
  • server
By Greg Nowak, 23 September, 2021

Ubuntu Logs Journalctl and Dmesg

You can see a lot of good information for debugging and fixing errors on your Ubuntu server with journalctl and dmesg

journalctl --since "1 days ago"

journalctl --since "10 hours ago"

journalctl --since "12 hours ago" -p 3 -x --utc --no-pager

dmesg | less

dmesg -H --time-format iso| less

Resources:

https://unix.stackexchange.com/questions/50098/linux-network-troublesho…

Tags

  • Linux
  • logistics
  • Script
By Greg Nowak, 23 September, 2021

Wordpress Cron

Wordpress runs it's cron job automatically approximately every 10 minutes. Sometimes it is blocked by .htaccess or other server configuration. To avoid issues, it might be a good idea to run from the server crontab itself.

References:

https://kinsta.com/knowledgebase/disable-wp-cron/

https://wpbeaches.com/set-up-wordpress-wp-cron-php-to-run-manually/

Tags

  • wordpress
  • Linux
  • Script
By Greg Nowak, 22 September, 2021

Bash Find and Delete Files Older Than X Days

find [FOLDER_NAME]/* -prune -mtime +14 -exec rm {} \;

Tags

  • Script
  • Linux
By Greg Nowak, 6 September, 2021

Nagios Check HTTP notes

Example bash on argument 1. It checks if HTTPS is up and if the domain-name is on the site. Most sites have the domain name on the front page somewhere: /usr/local/nagios/libexec/check_http -H $1 --ssl --onredirect=follow --string "$1"

If log file you can run grep on the following keywords: grep -i -e "critical" -e "invalid" -e "warning"  [LOGFILE.log]

Keywords: check_http

Tags

  • Script
  • Linux
  • Web
By Greg Nowak, 24 August, 2021

Ubuntu Linux Flush DNS Cache

sudo resolvectl flush-caches

Before Ubuntu 22.04

Check DNS cache status: sudo systemd-resolve --statistics

Flush DNS cache: sudo systemd-resolve --flush-caches

Tags

  • Linux
  • Script
By Greg Nowak, 11 August, 2021

SystemD Notes Tips and Tricks

A nice little guide: https://tecadmin.net/run-shell-script-as-systemd-service/

Tags

  • Linux
  • Script
By Greg Nowak, 6 August, 2021

Mysqldump encoding

If you experience false characters in your mysqldump, you might want to try to set the encoding specifically. Example with latin1:

mysqldump -u [USER] -p --opt --skip-set-charset --default-character-set=latin1 [DATABASE_NAME] > [OUTPUT_FILE_NAME].sql

Check different encoding settings in mysql when using a specific database: show variables like 'char%';

More info and tips: https://www.toptal.com/php/a-utf-8-primer-for-php-and-mysql

Tags

  • Script
  • Linux

Pagination

  • 1
  • Next page
Script

Review Greg on Google

Greg Nowak Google Reviews

 

  • Portfolio
  • About Greg Nowak
  • Gregs IT and Logistics Optimization
  • Shrink PDF In Linux
  • Running Linux on T450s T495s T14, Thinkpads and Others
RSS feed

GrN.dk web platforms, web optimization, data analysis, data handling and logistics.